454. 四数相加 II[https://leetcode.cn/problems/4sum-ii/] 思路example四个数组相同长度第一步:brute-force: h...
454. 四数相加 II[https://leetcode.cn/problems/4sum-ii/] 思路example四个数组相同长度第一步:brute-force: h...
204. Count Primes[https://leetcode.cn/problems/count-primes/] 思路example素数筛选法 n/2 + n/3 ...
DFS 岛屿系列题目 200. Number of Islands[https://leetcode.cn/problems/number-of-islands/] 思路ex...
如果节点 p 和 q 连通的话,一定拥有相同的根节点 复杂度:O(n) 平衡性优化, 复杂度:O(log n) 路径压缩进一步压缩每棵树的高度,使树高始终保持为常数 Unio...
207. Course Schedule[https://leetcode.cn/problems/course-schedule/] 思路example有向图 graph[...
前缀和 差分数组的主要适用场景是频繁对原始数组的某个区间的元素进行增减。 如果你想对区间 nums[i..j] 的元素全部加 3,那么只需要让 diff[i] += 3,然后...
303. Range Sum Query - Immutable[https://leetcode.cn/problems/range-sum-query-immutable...
小结 合并两个有序链表 链表的分解 合并 k 个有序链表 寻找单链表的倒数第 k 个节点 寻找单链表的中点 判断单链表是否包含环并找出环起点 判断两个单链表是否相交并找出交点...
('a' | ' ') = 'a'('A' | ' ') = 'a'('b' & '_') = 'B'('B' & '_') = 'B'('d' ^ ' ') = 'D'('...
657. 机器人能否返回原点[https://leetcode.cn/problems/robot-return-to-origin/] 思路example计数 R - L ...
685. 冗余连接 II[https://leetcode.cn/problems/redundant-connection-ii/] 思路example有向图,并查集 有根...
684. 冗余连接[https://leetcode.cn/problems/redundant-connection/] 思路example并查集 并查集主要有三个功能。寻...
841. 钥匙和房间[https://leetcode.cn/problems/keys-and-rooms/] 思路example图有向图 (有起点和终点)连通分支 (但是...
132. 分割回文串 II[https://leetcode.cn/problems/palindrome-partitioning-ii/] 思路example最少分割次数...
1221. 分割平衡字符串[https://leetcode.cn/problems/split-a-string-in-balanced-strings/] 思路examp...
52. N皇后 II[https://leetcode.cn/problems/n-queens-ii/] 思路example暴力回溯 复杂度. 时间:O(?), 空间: O...
129. 求根节点到叶节点数字之和[https://leetcode.cn/problems/sum-root-to-leaf-numbers/] 思路example递归:前...
925. 长按键入[https://leetcode.cn/problems/long-pressed-name/] 思路example双指针一个字符串一个指针遍历比较, 计...
205. 同构字符串[https://leetcode.cn/problems/isomorphic-strings/] 思路example假设:t.length == s....