ICode9

精准搜索请尝试: 精确搜索
  • LeetCode 128 Longest Consecutive Sequence2022-09-17 04:30:19

    Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in \(O(n)\) time. Solution 既然不能排序,那就用 \(set\) 将元素全部存进去。从所有可能序列中的最小开始遍历,逐次递增,然后

  • 自动产生configure2022-09-15 13:31:44

    #!/bin/bash dir=$(pwd) echo $dir cd $dir rm -rf cur cp test cur -r cd cur autoscan name=configure.ac mv configure.scan $name sed -i 's|AC_OUTPUT|AC_OUTPUT(Makefile)|g' $name sed -i 's|\[FULL-PACKAGE-NAME\]|demo|g' $name sed -i 

  • leetcode 78. 子集 js 实现2022-09-14 01:30:09

    给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。 解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。 示例 1: 输入:nums = [1,2,3]输出:[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]示例 2: 输入:nums = [0]输出:[[],[0]]  提示: 1 <= nums.leng

  • 701.insert-into-a-binary-search-tree 二叉搜索树中的插入操作2022-09-12 19:02:15

    没啥好说的,但是要注意连续两个if和if... else if之间的区别。 class Solution { public: TreeNode *insertIntoBST(TreeNode *root, int val) { if (root == nullptr) { TreeNode *res = new TreeNode(val); return res; }

  • Map和Set (搜索树)2022-09-10 21:32:04

    1.搜索 1.1概念 Map和set是一种专门用来进行搜索的容器或者数据结构,其搜索的效率与其具体的实例化子类有关.常见的搜索方式有两种 1直接遍历,时间复杂度为O(N),元素多时相对效率低, 2二分查找,时间复杂度为O(logN),搜索的前提必须是有序数列   1.2模型 1  纯Key模型  如 查找字

  • Petrozavodsk Summer 2022. Day 1. Welcome Contest2022-09-10 11:30:37

    Petrozavodsk Summer 2022. Day 1. Welcome Contest 是不是又开新坑了,毛营我来了! 挑几道自己会的 & 有意思 的题写题解 QwQ D - Double Sort 给定 \(n,m(n\leq m)\),随机一个值域在 \([1,m]\) 且数字不重复的的长度为 \(n\) 的序列 \(a_i\)。 令 \(a_0=0\),将 \(a\) 数组排序,差分,再

  • 98.validate-binary-search-tree 验证二叉搜索树2022-09-06 14:31:28

    二叉搜索树定义: 节点左子树只包含小于当前节点的数; 节点右子树只包含大于当前节点的数; 所有左子树和右子树自身必须也是二叉搜索树。 实际上,若中序遍历二叉搜索树,所得序列是单调递增的,利用这一性质来判断是否是二叉搜索树。 递归法 创建一个指针pre,指向中序遍历过程中的当前节点

  • 算法--链表2022-09-04 21:01:43

          方法一:构造链表 如果此类型的题出现在笔试中,如果内存要求不高,可以采用如下方法:可以先用一个vector将单链表的指针都存起来,然后再构造链表。此方法简单易懂,代码好些。 /* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL

  • 设计链表2022-09-04 17:04:48

    设计链表 设计链表的实现。您可以选择使用单链表或双链表。单链表中的节点应该具有两个属性:val 和 next。val 是当前节点的值,next 是指向下一个节点的指针/引用。如果要使用双向链表,则还需要一个属性 prev 以指示链表中的上一个节点。假设链表中的所有节点都是 0-index 的。 在链

  • leetcode 面试题08.08 有重复字符串的排列组合 C/C++ 排序 + 深度优先搜索(分支限界)2022-09-04 01:31:37

    #include<iostream>#include<algorithm>#include<vector>using namespace std;class Solution {public: vector<string> permutation(string S) { sort(S.begin(),S.end()); vector<string> retVec; vector<int>

  • SQLServer重建索引2022-09-03 23:05:34

      查询碎片率 SELECT a.index_id ,B.name [IndexName] ,avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats ( DB_ID() , NULL , NULL, NULL, NULL ) AS A JOIN sys.indexes AS B ON a.object_id = b.object_id AND a.index_id = b.index_id inner JOIN sys.tab

  • 移除链表元素2022-09-02 21:34:53

    移除链表元素 难度简单1013收藏分享切换为英文接收动态反馈 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。 示例 1: 输入:head = [1,2,6,3,4,5,6], val = 6 输出:[1,2,3,4,5] 示例 2: 输入:head = [], val = 1 输出:[

  • 206 反转链表2022-09-01 20:05:30

    题目206 反转链表 给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。 示例 1: 输入:head = [1,2,3,4,5] 输出:[5,4,3,2,1] 示例 2: 输入:head = [1,2] 输出:[2,1] 示例 3: 输入:head = [] 输出:[] 双指针思路: 定义指针cur指向head,定义指针pre,定义为None,作为链表的最后节点的指向

  • 11. 盛最多水的容器2022-09-01 13:30:24

    11. 盛最多水的容器 给定一个长度为 n 的整数数组 height 。有 n 条垂线,第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 返回容器可以储存的最大水量。 说明:你不能倾斜容器。   示例 1: 输入

  • 力扣 110. 平衡二叉树 [基础+优化]2022-08-31 14:30:08

    110. 平衡二叉树 给定一个二叉树,判断它是否是高度平衡的二叉树。 本题中,一棵高度平衡二叉树定义为: 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1 。   示例 1: 输入:root = [3,9,20,null,null,15,7] 输出:true 示例 2: 输入:root = [1,2,2,3,3,null,null,4,4

  • NowCoder BM1 反转链表2022-08-31 13:31:34

    描述 给定一个单链表的头结点pHead(该头节点是有值的,比如在下图,它的val是1),长度为n,反转该链表后,返回新链表的表头。 NowCoder BM1 反转链表 import java.util.*; /* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val =

  • 83. 删除排序链表中的重复元素2022-08-30 15:03:17

    83. 删除排序链表中的重复元素 # 由于是已排序的链表,判断前后是否为相同元素如果是则连接下下个不是则向前移动 #code: # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = ne

  • LeetCode 854. K-Similar Strings2022-08-29 05:30:44

    原题链接在这里:https://leetcode.com/problems/k-similar-strings/ 题目: Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2. Given t

  • cur·ren·cy2022-08-27 08:00:24

    Origin: currentia 'flowing', from Latin currere; current A currency in the most specific sense is money in any form when in use or circulation as a medium of exchange, especially circulating banknotes and coins. A more general definition is that

  • 10.异步mysql2022-08-21 23:31:15

    python中操作mysql连接、操作、断开都是网络IO #安装支持异步aiomysql的模块 pip3 install aiomysql async def execute(): # 网络IO操作,连接数据库,遇到IO切换任务 conn = await aiomysql.connect('host', 3306, 'root', 'password', 'db') # 网络IO操作,遇到IO自动

  • 在网站上更改鼠标样式2022-08-21 20:33:26

    笔者研究了一下,发现仅通过CSS(不知道还有没有别的方法)没办法达到笔者真正想改变鼠标指针样式的目的 和自己在电脑上安装鼠标指针样式不同,网站上鼠标指针没法根据鼠标指针自身状态而更改样式,而只能通过CSS选择器,根据网页元素的状态来更改鼠标指针样式 CSS选择器参考手册 https://ww

  • [题解] Atcoder Regular Contest ARC 146 A B C D 题解2022-08-21 14:00:08

    点我看题 A - Three Cards 先把所有数按位数从多到少排序,答案的位数一定等于位数最多的三个数的位数之和\(tot\)。对于每个i,把有i位的数排序,并记录每个i的排序结果。最后枚举答案中三个数最靠前的数\(a_i\),然后枚举第二个数的长度\(lenj\),取长度为lenj的数中最大的。如果这个最大

  • 删除链表结点类问题2022-08-21 03:01:59

    删除链表结点 NO1. 删除链表倒数第 k个结点 给定一个链表,删除链表的倒数第 n 个节点并返回链表的头指针。要求:空间复杂度 \(O(1)\),时间复杂度 \(O(n)\) 如果倒数第 k 个结点刚好是头结点,那头结点需要特殊处理。为了各个结点能等同操作,设置一个虚拟头结点。 寻找倒数第 k 个结点

  • PAT Advanced 1021 Deepest Root(25)2022-08-20 22:31:11

    题目描述: A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is called the deepest root. Input Specification:

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有