diff --git a/Assets/Origins/Interview-100-List.md b/Assets/Origins/Interview-100-List.md new file mode 100644 index 00000000..ded9fa95 --- /dev/null +++ b/Assets/Origins/Interview-100-List.md @@ -0,0 +1,196 @@ +## 01. 数组 + +### [数组基础题目](../../Contents/01.Array/01.Array-Basic/02.Array-Basic-List.md) + +###### 0054. 螺旋矩阵、0048. 旋转图像 + +### [排序算法题目](../../Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md) + +#### 选择排序题目 + +###### 0215. 数组中的第K个最大元素 + +#### 希尔排序题目 + +###### 0912. 排序数组 + +#### 归并排序题目 + +###### 0912. 排序数组、0088. 合并两个有序数组 + +#### 快速排序题目 + +###### 0912. 排序数组、0169. 多数元素 + +#### 堆排序题目 + +###### 0912. 排序数组、0215. 数组中的第K个最大元素 + +#### 计数排序题目 + +###### 0912. 排序数组 + +#### 桶排序题目 + +###### 0912. 排序数组 + +#### 其他排序题目 + +###### 0136. 只出现一次的数字、0056. 合并区间、0179. 最大数 + + +### [二分查找题目](../../Contents/01.Array/03.Array-Binary-Search/02.Array-Binary-Search-List.md) + +#### 二分下标题目 + +###### 0704. 二分查找、0034. 在排序数组中查找元素的第一个和最后一个位置、0153. 寻找旋转排序数组中的最小值、0033. 搜索旋转排序数组、0162. 寻找峰值、0004. 寻找两个正序数组的中位数、0240. 搜索二维矩阵 II + +#### 二分答案题目 + +###### 0069. x 的平方根 + +### [双指针题目](../../Contents/01.Array/04.Array-Two-Pointers/02.Array-Two-Pointers-List.md) + +#### 对撞指针题目 + +###### 0015. 三数之和 + +#### 快慢指针题目 + +###### 0283. 移动零、0088. 合并两个有序数组 + +#### 分离双指针题目 + +###### 0415. 字符串相加 + +### [滑动窗口题目](../../Contents/01.Array/05.Array-Sliding-Window/02.Array-Sliding-Window-List.md) + +#### 固定长度窗口题目 + +###### 0239. 滑动窗口最大值 + +#### 不定长度窗口题目 + +###### 0003. 无重复字符的最长子串、0076. 最小覆盖子串、0718. 最长重复子数组 + +## 02. 链表 + +### [链表经典题目](../../Contents/02.Linked-List/01.Linked-List-Basic/02.Linked-List-Basic-List.md) + +###### 0083. 删除排序链表中的重复元素、0082. 删除排序链表中的重复元素 II、0206. 反转链表、0092. 反转链表 II、0025. K 个一组翻转链表、0234. 回文链表 + +### [链表排序题目](../../Contents/02.Linked-List/02.Linked-List-Sort/02.Linked-List-Sort-List.md) + +###### 0148. 排序链表、0021. 合并两个有序链表、0023. 合并K个升序链表 + +### [链表双指针题目](../../Contents/02.Linked-List/03.Linked-List-Two-Pointers/02.Linked-List-Two-Pointers-List.md) + +###### 0141. 环形链表、0142. 环形链表 II、0160. 相交链表、0019. 删除链表的倒数第 N 个结点、剑指 Offer 22. 链表中倒数第k个节点、0143. 重排链表、0002. 两数相加 + +## 03. 堆栈 + +### [堆栈基础题目](../../Contents/03.Stack/01.Stack-Basic/02.Stack-Basic-List.md) + +###### 0155. 最小栈、0020. 有效的括号、0227. 基本计算器 II、0232. 用栈实现队列、0394. 字符串解码、0032. 最长有效括号 + +### [单调栈](../../Contents/03.Stack/02.Monotone-Stack/02.Monotone-Stack-List.md) + +###### 0042. 接雨水 + +## 04. 队列 + +### [队列基础题目](../../Contents/04.Queue/01.Queue-Basic/02.Queue-Basic-List.md) + +###### 0225. 用队列实现栈 + +### [优先队列题目](../../Contents/04.Queue/02.Priority-Queue/02.Priority-Queue-List.md) + +###### 0023. 合并K个升序链表、0239. 滑动窗口最大值 + +## 05. 哈希表 + +### [哈希表题目](../../Contents/05.Hash-Table/02.Hash-Table-List.md) + +###### 0001. 两数之和、0015. 三数之和、0041. 缺失的第一个正数、0128. 最长连续序列、0136. 只出现一次的数字 + +## 06. 字符串 + +### [字符串基础题目](../../Contents/06.String/01.String-Basic/02.String-Basic-List.md) + +###### 0003. 无重复字符的最长子串、0005. 最长回文子串、0415. 字符串相加、0151. 颠倒字符串中的单词、0043. 字符串相乘、0014. 最长公共前缀 + +## 07. 树 + +### [二叉树的遍历题目](../../Contents/07.Tree/01.Binary-Tree/03.Binary-Tree-Traverse-List.md) + +###### 0144. 二叉树的前序遍历、0094. 二叉树的中序遍历、0102. 二叉树的层序遍历、0103. 二叉树的锯齿形层序遍历、0236. 二叉树的最近公共祖先、0104. 二叉树的最大深度、0112. 路径总和、0113. 路径总和 II、0101. 对称二叉树、0124. 二叉树中的最大路径和、0199. 二叉树的右视图、0226. 翻转二叉树 + +### [二叉树的还原题目](../../Contents/07.Tree/01.Binary-Tree/05.Binary-Tree-Reduction-List.md) + +###### 0105. 从前序与中序遍历序列构造二叉树 + +### [二叉搜索树题目](../../Contents/07.Tree/02.Binary-Search-Tree/02.Binary-Search-Tree-List.md) + +###### 0098. 验证二叉搜索树、0110. 平衡二叉树 + +### [并查集题目](../../Contents/07.Tree/05.Union-Find/02.Union-Find-List.md) + +###### 0128. 最长连续序列 + +## 08. 图论 + +### [图的深度优先搜索题目](../../Contents/08.Graph/02.Graph-Traversal/02.Graph-DFS-List.md) + +###### 0200. 岛屿数量、0695. 岛屿的最大面积、0144. 二叉树的前序遍历、0094. 二叉树的中序遍历、0129. 求根节点到叶节点数字之和、0124. 二叉树中的最大路径和、0199. 二叉树的右视图、0543. 二叉树的直径、0662. 二叉树最大宽度 + +### [图的广度优先搜索题目](../../Contents/08.Graph/02.Graph-Traversal/04.Graph-BFS-List.md) + +###### 0200. 岛屿数量、0322. 零钱兑换、0199. 二叉树的右视图、0662. 二叉树最大宽度 + +## 09. 基础算法 + +### [枚举算法题目](../../Contents/09.Algorithm-Base/01.Enumeration-Algorithm/02.Enumeration-Algorithm-List.md) + +###### 0001. 两数之和、0078. 子集、0221. 最大正方形 + +### [递归算法题目](../../Contents/09.Algorithm-Base/02.Recursive-Algorithm/02.Recursive-Algorithm-List.md) + +###### 0024. 两两交换链表中的节点、0206. 反转链表、0092. 反转链表 II、0021. 合并两个有序链表、0070. 爬楼梯、0104. 二叉树的最大深度、0124. 二叉树中的最大路径和、0226. 翻转二叉树 + +### [分治算法题目](../../Contents/09.Algorithm-Base/03.Divide-And-Conquer-Algorithm/02.Divide-And-Conquer-Algorithm-List.md) + +###### 0053. 最大子数组和、0023. 合并K个升序链表、0004. 寻找两个正序数组的中位数、0169. 多数元素、0014. 最长公共前缀 + +### [回溯算法题目](../../Contents/09.Algorithm-Base/04.Backtracking-Algorithm/02.Backtracking-Algorithm-List.md) + +###### 0046. 全排列、0022. 括号生成、0078. 子集、0039. 组合总和、0093. 复原 IP 地址 + +### [贪心算法题目](../../Contents/09.Algorithm-Base/05.Greedy-Algorithm/02.Greedy-Algorithm-List.md) + +###### 0053. 最大子数组和、0056. 合并区间、0122. 买卖股票的最佳时机 II + +### [位运算题目](../../Contents/09.Algorithm-Base/06.Bit-Operation/02.Bit-Operation-List.md) + +###### 0136. 只出现一次的数字 + +## 10. 动态规划 + +### [动态规划题目](../../Contents/10.Dynamic-Programming/01.Dynamic-Programming-Basic/02.Dynamic-Programming-Basic-List.md) + +###### 0070. 爬楼梯、0121. 买卖股票的最佳时机、0322. 零钱兑换、0300. 最长递增子序列、1143. 最长公共子序列、0718. 最长重复子数组、0064. 最小路径和、0072. 编辑距离、0032. 最长有效括号、0221. 最大正方形、0062. 不同路径、0152. 乘积最大子数组、0198. 打家劫舍 + + +## 11. 补充题目 + +#### 设计数据结构题目 + +###### 0146. LRU 缓存 + +#### 模拟题目 + +###### 0008. 字符串转换整数 (atoi)、0165. 比较版本号、0468. 验证IP地址 + +#### 思维锻炼题目 + +###### 0031. 下一个排列、0470. 用 Rand7() 实现 Rand10() + diff --git a/Assets/Origins/Interview-200-List.md b/Assets/Origins/Interview-200-List.md new file mode 100644 index 00000000..39a93ff2 --- /dev/null +++ b/Assets/Origins/Interview-200-List.md @@ -0,0 +1,234 @@ +## 01. 数组 + +### [数组基础题目](../../Contents/01.Array/01.Array-Basic/02.Array-Basic-List.md) + +###### 0189. 轮转数组、0498. 对角线遍历、0054. 螺旋矩阵、0059. 螺旋矩阵 II、0048. 旋转图像 + +### [排序算法题目](../../Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md) + +#### 冒泡排序题目 + +###### 0283. 移动零 + +#### 选择排序题目 + +###### 0215. 数组中的第K个最大元素 + +#### 插入排序题目 + +###### 0075. 颜色分类 + +#### 希尔排序题目 + +###### 0912. 排序数组 + +#### 归并排序题目 + +###### 0912. 排序数组、0088. 合并两个有序数组、剑指 Offer 51. 数组中的逆序对 + +#### 快速排序题目 + +###### 0912. 排序数组、0169. 多数元素 + +#### 堆排序题目 + +###### 0912. 排序数组、0215. 数组中的第K个最大元素、剑指 Offer 40. 最小的k个数 + +#### 计数排序题目 + +###### 0912. 排序数组 + +#### 桶排序题目 + +###### 0912. 排序数组 + +#### 基数排序题目 + +###### 0164. 最大间距 + +#### 其他排序题目 + +###### 0136. 只出现一次的数字、0056. 合并区间、0179. 最大数、0384. 打乱数组、剑指 Offer 45. 把数组排成最小的数 + + +### [二分查找题目](../../Contents/01.Array/03.Array-Binary-Search/02.Array-Binary-Search-List.md) + +#### 二分下标题目 + +###### 0704. 二分查找、0034. 在排序数组中查找元素的第一个和最后一个位置、0153. 寻找旋转排序数组中的最小值、0154. 寻找旋转排序数组中的最小值 II、0033. 搜索旋转排序数组、0162. 寻找峰值、0004. 寻找两个正序数组的中位数、0074. 搜索二维矩阵、0240. 搜索二维矩阵 II + +#### 二分答案题目 + +###### 0069. x 的平方根、0287. 寻找重复数、0050. Pow(x, n)、0400. 第 N 位数字 + +#### 复杂的二分查找问题 + +###### 0209. 长度最小的子数组、0349. 两个数组的交集 + +### [双指针题目](../../Contents/01.Array/04.Array-Two-Pointers/02.Array-Two-Pointers-List.md) + +#### 对撞指针题目 + +###### 0611. 有效三角形的个数、0015. 三数之和、0016. 最接近的三数之和、0125. 验证回文串、0011. 盛最多水的容器、0075. 颜色分类、剑指 Offer 21. 调整数组顺序使奇数位于偶数前面、0443. 压缩字符串 + +#### 快慢指针题目 + +###### 0026. 删除有序数组中的重复项、0283. 移动零、0088. 合并两个有序数组 + +#### 分离双指针题目 + +###### 0415. 字符串相加 + +### [滑动窗口题目](../../Contents/01.Array/05.Array-Sliding-Window/02.Array-Sliding-Window-List.md) + +#### 固定长度窗口题目 + +###### 0239. 滑动窗口最大值 + +#### 不定长度窗口题目 + +###### 0003. 无重复字符的最长子串、0076. 最小覆盖子串、0718. 最长重复子数组、0209. 长度最小的子数组、0862. 和至少为 K 的最短子数组、1004. 最大连续1的个数 III + +## 02. 链表 + +### [链表经典题目](../../Contents/02.Linked-List/01.Linked-List-Basic/02.Linked-List-Basic-List.md) + +###### 0083. 删除排序链表中的重复元素、0082. 删除排序链表中的重复元素 II、0206. 反转链表、0092. 反转链表 II、0328. 奇偶链表、0025. K 个一组翻转链表、0234. 回文链表、0138. 复制带随机指针的链表、0061. 旋转链表 + +### [链表排序题目](../../Contents/02.Linked-List/02.Linked-List-Sort/02.Linked-List-Sort-List.md) + +###### 0148. 排序链表、0021. 合并两个有序链表、0023. 合并K个升序链表 + +### [链表双指针题目](../../Contents/02.Linked-List/03.Linked-List-Two-Pointers/02.Linked-List-Two-Pointers-List.md) + +###### 0141. 环形链表、0142. 环形链表 II、0160. 相交链表、0019. 删除链表的倒数第 N 个结点、剑指 Offer 22. 链表中倒数第k个节点、0143. 重排链表、0002. 两数相加、0445. 两数相加 II + +## 03. 堆栈 + +### [堆栈基础题目](../../Contents/03.Stack/01.Stack-Basic/02.Stack-Basic-List.md) + +###### 1047. 删除字符串中的所有相邻重复项、0155. 最小栈、0020. 有效的括号、0224. 基本计算器、0227. 基本计算器 II、0232. 用栈实现队列、剑指 Offer 09. 用两个栈实现队列、0394. 字符串解码、0032. 最长有效括号、0739. 每日温度、0071. 简化路径 + +### [单调栈](../../Contents/03.Stack/02.Monotone-Stack/02.Monotone-Stack-List.md) + +###### 0739. 每日温度、0503. 下一个更大元素 II、0042. 接雨水、0085. 最大矩形 + +## 04. 队列 + +### [队列基础题目](../../Contents/04.Queue/01.Queue-Basic/02.Queue-Basic-List.md) + +###### 0225. 用队列实现栈 + +### [优先队列题目](../../Contents/04.Queue/02.Priority-Queue/02.Priority-Queue-List.md) + +###### 0295. 数据流的中位数、0347. 前 K 个高频元素、0023. 合并K个升序链表、0239. 滑动窗口最大值 + +## 05. 哈希表 + +### [哈希表题目](../../Contents/05.Hash-Table/02.Hash-Table-List.md) + +###### 0001. 两数之和、0015. 三数之和、0041. 缺失的第一个正数、0128. 最长连续序列、0136. 只出现一次的数字、0242. 有效的字母异位词、0442. 数组中重复的数据、剑指 Offer 61. 扑克牌中的顺子、0268. 丢失的数字、剑指 Offer 03. 数组中重复的数字 + +## 06. 字符串 + +### [字符串基础题目](../../Contents/06.String/01.String-Basic/02.String-Basic-List.md) + +###### 0003. 无重复字符的最长子串、0125. 验证回文串、0005. 最长回文子串、0344. 反转字符串、0557. 反转字符串中的单词 III、0415. 字符串相加、0151. 颠倒字符串中的单词、0043. 字符串相乘、0014. 最长公共前缀 + +### [单模式串匹配题目](../../Contents/06.String/02.String-Single-Pattern-Matching/07.String-Single-Pattern-Matching-List.md) + +###### 0459. 重复的子字符串 + +### [字典树题目](../../Contents/06.String/03.String-Multi-Pattern-Matching/02.Trie-List.md) + +###### 0208. 实现 Trie (前缀树)、0440. 字典序的第K小数字 + +## 07. 树 + +### [二叉树的遍历题目](../../Contents/07.Tree/01.Binary-Tree/03.Binary-Tree-Traverse-List.md) + +###### 0144. 二叉树的前序遍历、0094. 二叉树的中序遍历、0145. 二叉树的后序遍历、0102. 二叉树的层序遍历、0103. 二叉树的锯齿形层序遍历、0236. 二叉树的最近公共祖先、0104. 二叉树的最大深度、0112. 路径总和、0113. 路径总和 II、0101. 对称二叉树、0124. 二叉树中的最大路径和、0199. 二叉树的右视图、0226. 翻转二叉树、0297. 二叉树的序列化与反序列化、0958. 二叉树的完全性检验、0572. 另一棵树的子树、0114. 二叉树展开为链表、0100. 相同的树、0111. 二叉树的最小深度 + +### [二叉树的还原题目](../../Contents/07.Tree/01.Binary-Tree/05.Binary-Tree-Reduction-List.md) + +###### 0105. 从前序与中序遍历序列构造二叉树、0106. 从中序与后序遍历序列构造二叉树 + +### [二叉搜索树题目](../../Contents/07.Tree/02.Binary-Search-Tree/02.Binary-Search-Tree-List.md) + +###### 0098. 验证二叉搜索树、0450. 删除二叉搜索树中的节点、0426. 将二叉搜索树转化为排序的双向链表、剑指 Offer 54. 二叉搜索树的第k大节点、0230. 二叉搜索树中第K小的元素、0110. 平衡二叉树 + +### [并查集题目](../../Contents/07.Tree/05.Union-Find/02.Union-Find-List.md) + +###### 0128. 最长连续序列 + +## 08. 图论 + +### [图的深度优先搜索题目](../../Contents/08.Graph/02.Graph-Traversal/02.Graph-DFS-List.md) + +###### 0200. 岛屿数量、0695. 岛屿的最大面积、0144. 二叉树的前序遍历、0094. 二叉树的中序遍历、0145. 二叉树的后序遍历、0129. 求根节点到叶节点数字之和、0124. 二叉树中的最大路径和、0199. 二叉树的右视图、0543. 二叉树的直径、0662. 二叉树最大宽度、0958. 二叉树的完全性检验、0572. 另一棵树的子树、0100. 相同的树、0111. 二叉树的最小深度 + +### [图的广度优先搜索题目](../../Contents/08.Graph/02.Graph-Traversal/04.Graph-BFS-List.md) + +###### 0200. 岛屿数量、0322. 零钱兑换、0199. 二叉树的右视图、0662. 二叉树最大宽度、0958. 二叉树的完全性检验、0207. 课程表、0572. 另一棵树的子树、0100. 相同的树、0111. 二叉树的最小深度、剑指 Offer 32 - III. 从上到下打印二叉树 III + +### [图的拓扑排序题目](../../Contents/08.Graph/02.Graph-Traversal/06.Graph-Topological-Sorting-List.md) + +###### 0210. 课程表 II + +## 09. 基础算法 + +### [枚举算法题目](../../Contents/09.Algorithm-Base/01.Enumeration-Algorithm/02.Enumeration-Algorithm-List.md) + +###### 0001. 两数之和、0078. 子集、0221. 最大正方形、0560. 和为 K 的子数组 + +### [递归算法题目](../../Contents/09.Algorithm-Base/02.Recursive-Algorithm/02.Recursive-Algorithm-List.md) + +###### 0024. 两两交换链表中的节点、0206. 反转链表、0092. 反转链表 II、0021. 合并两个有序链表、0509. 斐波那契数、0070. 爬楼梯、0104. 二叉树的最大深度、0124. 二叉树中的最大路径和、0226. 翻转二叉树、剑指 Offer 62. 圆圈中最后剩下的数字 + +### [分治算法题目](../../Contents/09.Algorithm-Base/03.Divide-And-Conquer-Algorithm/02.Divide-And-Conquer-Algorithm-List.md) + +###### 0053. 最大子数组和、0023. 合并K个升序链表、0004. 寻找两个正序数组的中位数、0169. 多数元素、0014. 最长公共前缀、剑指 Offer 33. 二叉搜索树的后序遍历序列 + +### [回溯算法题目](../../Contents/09.Algorithm-Base/04.Backtracking-Algorithm/02.Backtracking-Algorithm-List.md) + +###### 0046. 全排列、0047. 全排列 II、0037. 解数独、0022. 括号生成、0078. 子集、0039. 组合总和、0040. 组合总和 II、0093. 复原 IP 地址、0079. 单词搜索、0679. 24 点游戏 + +### [贪心算法题目](../../Contents/09.Algorithm-Base/05.Greedy-Algorithm/02.Greedy-Algorithm-List.md) + +###### 0053. 最大子数组和、0056. 合并区间、0122. 买卖股票的最佳时机 II、0055. 跳跃游戏、0402. 移掉 K 位数字、0135. 分发糖果、0134. 加油站、0670. 最大交换 + +### [位运算题目](../../Contents/09.Algorithm-Base/06.Bit-Operation/02.Bit-Operation-List.md) + +###### 0136. 只出现一次的数字、0191. 位1的个数、0268. 丢失的数字 + +## 10. 动态规划 + +### [动态规划题目](../../Contents/10.Dynamic-Programming/01.Dynamic-Programming-Basic/02.Dynamic-Programming-Basic-List.md) + +###### 0070. 爬楼梯、0509. 斐波那契数、0121. 买卖股票的最佳时机、0322. 零钱兑换、0518. 零钱兑换 II、0300. 最长递增子序列、1143. 最长公共子序列、0718. 最长重复子数组、0064. 最小路径和、0072. 编辑距离、0032. 最长有效括号、0221. 最大正方形、0062. 不同路径、0063. 不同路径 II、0152. 乘积最大子数组、0198. 打家劫舍、0213. 打家劫舍 II、0091. 解码方法、0010. 正则表达式匹配、0678. 有效的括号字符串、0045. 跳跃游戏 II、0673. 最长递增子序列的个数、0139. 单词拆分、0044. 通配符匹配、0120. 三角形最小路径和、0096. 不同的二叉搜索树、0887. 鸡蛋掉落、0097. 交错字符串、0516. 最长回文子序列 + +### 记忆化搜索题目 + +###### 0329. 矩阵中的最长递增路径 + +## 11. 补充题目 + +#### 设计数据结构题目 + +###### 0146. LRU 缓存、0460. LFU 缓存 + +#### 数学题目 + +###### 0007. 整数反转、0009. 回文数、剑指 Offer 62. 圆圈中最后剩下的数字、0168. Excel表列名称、0400. 第 N 位数字 + +#### 模拟题目 + +###### 0008. 字符串转换整数 (atoi)、0165. 比较版本号、0468. 验证IP地址、0086. 分隔链表 + +#### 前缀和 + +###### 0560. 和为 K 的子数组 + +#### 思维锻炼题目 + +###### 0031. 下一个排列、0556. 下一个更大元素 III、0470. 用 Rand7() 实现 Rand10() \ No newline at end of file diff --git a/Assets/Origins/README-Catalogue-List.md b/Assets/Origins/README-Catalogue-List.md index 872b81f5..cf3a68b7 100644 --- a/Assets/Origins/README-Catalogue-List.md +++ b/Assets/Origins/README-Catalogue-List.md @@ -7,6 +7,8 @@ - [LeetCode 入门与攻略](https://github.com/itcharge/LeetCode-Py/blob/main/Contents/00.Introduction/03.LeetCode-Guide.md) - [LeetCode 题解(字典序排序,650+ 道题解)](https://github.com/itcharge/LeetCode-Py/blob/main/Contents/00.Introduction/04.Solutions-List.md) - [LeetCode 题解(按分类排序,推荐刷题列表 ★★★)](https://github.com/itcharge/LeetCode-Py/blob/main/Contents/00.Introduction/05.Categories-List.md) +- [LeetCode 面试最常考 100 题(按分类排序)](https://github.com/itcharge/LeetCode-Py/blob/main/Contents/00.Introduction/06.Interview-100-List.md) +- [LeetCode 面试最常考 200 题(按分类排序)](https://github.com/itcharge/LeetCode-Py/blob/main/Contents/00.Introduction/07.Interview-200-List.md) ## 01. 数组 diff --git a/Assets/Origins/README-Head.md b/Assets/Origins/README-Head.md index 2fbcab4d..292e829c 100644 --- a/Assets/Origins/README-Head.md +++ b/Assets/Origins/README-Head.md @@ -2,7 +2,7 @@ ## 项目简介 -- **「算法与数据结构」** 基础知识的讲解教程,「LeetCode」650+ 道题目的详细解析。本项目易于理解,没有大跨度的思维跳跃,项目中使用部分图示、例子来帮助理解。 +- **「算法与数据结构」** 基础知识的讲解教程,「LeetCode」700+ 道题目的详细解析。本项目易于理解,没有大跨度的思维跳跃,项目中使用部分图示、例子来帮助理解。 - 本教程先从基础的数据结构和算法开始讲解,再针对不同分类的数据结构和算法,进行具体题目的讲解分析。让读者可以通过「算法基础理论学习」和「编程实战学习」相结合的方式,彻底的掌握算法知识。 @@ -26,7 +26,7 @@ 我是一名 iOS / macOS 的开发程序员,另外也是北航软院的一名非全硕士(在读)。曾在大学期间学习过算法知识,并参加过 3 年的 ACM 比赛, 但水平有限,未能取得理想成绩。但是这 3 年的 ACM 经历,给我最大的收获是锻炼了自己的逻辑思维和解决实际问题的能力,这种能力为我今后的工作、学习打下了坚实的基础。 -我从 2021 年 03 月 30 日开始每日在 LeetCode 刷题,到 2021 年 11 月 26 日已经刷了 700+ 道题目,并且完成了 650+ 道题解。努力向着 1000+、1500+、2000+ 道题前进。 +我从 2021 年 03 月 30 日开始每日在 LeetCode 刷题,到 2022 年 06 月 08 日已经刷了 1000+ 道题目,并且完成了 700+ 道题解。努力向着 1000+、1500+、2000+ 道题解前进。 在公众号 **「程序员充电站」** 里回复 "**算法打卡**",拉你进 LeetCode 算法打卡计划群一起组队打卡。 diff --git a/Assets/Origins/Root-Index-Head.md b/Assets/Origins/Root-Index-Head.md index 239eb59c..4c30ca08 100644 --- a/Assets/Origins/Root-Index-Head.md +++ b/Assets/Origins/Root-Index-Head.md @@ -69,7 +69,7 @@ 我是一名 iOS / macOS 的开发程序员,另外也是北航软院的一名非全硕士(在读)。曾在大学期间学习过算法知识,并参加过 3 年的 ACM 比赛, 但水平有限,未能取得理想成绩。但是这 3 年的 ACM 经历,给我最大的收获是锻炼了自己的逻辑思维和解决实际问题的能力,这种能力为我今后的工作、学习打下了坚实的基础。 -我从 2021 年 03 月 30 日开始每日在 LeetCode 刷题,到 2021 年 11 月 26 日已经刷了 700+ 道题目,并且完成了 650+ 道题解。努力向着 1000+、1500+、2000+ 道题前进。 +我从 2021 年 03 月 30 日开始每日在 LeetCode 刷题,到 2022 年 06 月 08 日已经刷了 1000+ 道题目,并且完成了 700+ 道题解。努力向着 1000+、1500+、2000+ 道题解前进。 ## 版权说明 diff --git a/Assets/Scripts/create_readme.py b/Assets/Scripts/create_readme.py index 9a561073..26d7b861 100644 --- a/Assets/Scripts/create_readme.py +++ b/Assets/Scripts/create_readme.py @@ -7,6 +7,15 @@ gen.gen_categories_list(solotions_path, categories_origin_list_path, categories_list_path) +# 生成面试 Top 100 题解列表 +interview_100_origin_list_path = '../Origins/Interview-100-List.md' +interview_100_list_path = '../../Contents/00.Introduction/06.Interview-100-List.md' +gen.gen_interview_list(solotions_path, interview_100_origin_list_path, interview_100_list_path) + +# 生成面试 Top 200 题解列表 +interview_200_origin_list_path = '../Origins/Interview-200-List.md' +interview_200_list_path = '../../Contents/00.Introduction/07.Interview-200-List.md' +gen.gen_interview_list(solotions_path, interview_200_origin_list_path, interview_200_list_path) # 生成全部题解列表 solotions_output_path = '../../Contents/00.Introduction/04.Solutions-List.md' diff --git a/Assets/Scripts/create_solutions_list.py b/Assets/Scripts/create_solutions_list.py index 730fe6f8..7eb38b85 100644 --- a/Assets/Scripts/create_solutions_list.py +++ b/Assets/Scripts/create_solutions_list.py @@ -62,7 +62,6 @@ def gen_solutions_list(solotions_path, solotions_output_path): if re.search(pattern_1, lines[i]): match_1 = pattern_1.finditer(lines[i]) for a in match_1: -# print(a) title_offer_id1, title_offer_id2, title_name, title_url = a.group(1,2,3,4) if title_offer_id2: title_offer_id = "剑指 Offer " + title_offer_id1 + title_offer_id2 @@ -74,7 +73,6 @@ def gen_solutions_list(solotions_path, solotions_output_path): if re.search(pattern_2, lines[i]): match_2 = pattern_2.finditer(lines[i]) for a in match_2: - print(a) title_offer_id1, title_name, title_url = a.group(1,2,3) title_offer_id = "剑指 Offer II " + title_offer_id1 continue @@ -83,7 +81,6 @@ def gen_solutions_list(solotions_path, solotions_output_path): if re.search(pattern_3, lines[i]): match_3 = pattern_3.finditer(lines[i]) for a in match_3: - print(a) title_offer_id1, title_offer_id2, title_name, title_url = a.group(1,2,3,4) title_offer_id = "面试题 " + title_offer_id1 + "." + title_offer_id2 continue @@ -92,7 +89,6 @@ def gen_solutions_list(solotions_path, solotions_output_path): pattern = re.compile(r'\[([0-9]\d*|0)+\. (.*)\]\((.*)\)') match = pattern.finditer(lines[i]) for a in match: - print(a) title_id, title_name, title_url = a.group(1,2,3) elif "标签" in lines[i]: pattern = re.compile(r'- 标签:(.*)') @@ -207,7 +203,6 @@ def gen_categories_list(solotions_path, categories_origin_list_path, categories_ category_file_content += "## " + category_h2 + "\n\n" elif title_size == "###": if category_h3 and category_h3_file_path and category_h3_file_content: -# print(category_h3_file_content) with open(category_h3_file_path, 'w') as fi: fi.write(category_h3_file_content) fi.close() @@ -252,11 +247,86 @@ def gen_categories_list(solotions_path, categories_origin_list_path, categories_ if category_file_content: with open(categories_list_path, 'w') as fi: + fi.write("# LeetCode 题解(按分类排序,推荐刷题列表 ★★★)\n\n") fi.write(category_file_content) fi.close() print("Create Categories List Success") + +# 根据题解目录, 面试题目分类原始列表目录,生成面试题解,并将整体保存到 interview_list_path +def gen_interview_list(solotions_path, interview_origin_list_path, interview_list_path): + + f = open(interview_origin_list_path) + lines = f.readlines() + interview_h2 = None + interview_h3 = None + interview_h4 = None + interview_h6 = None + interview_h3_file_path = None + interview_h3_file_content = "" + interview_file_content = "" + + problems_set = set() + for i in range(len(lines)): + pattern = re.compile(r'(#{2,6}) (.*)') + match = pattern.match(lines[i]) + if match: + title_size, title_content = match.group(1,2) + if title_size == "##": + interview_h2 = title_content + interview_file_content += "## " + interview_h2 + "\n\n" + elif title_size == "###": + if interview_h3 and interview_h3_file_path and interview_h3_file_content: + interview_h3 = None + interview_h3_file_path = None + interview_h3_file_content = "" + pattern1 = re.compile(r'\[(.*)\]\((.*)\)') + match1 = pattern1.match(title_content) + if match1: + interview_h3, interview_h3_file_path = match1.group(1,2) + interview_h3_file_content += "### " + interview_h3 + "\n\n" + interview_file_content += "### " + interview_h3 + "\n\n" + else: + interview_h3 = title_content + interview_file_content += "### " + interview_h3 + "\n\n" + elif title_size == "####": + interview_h4 = title_content + interview_h3_file_content += "#### " + interview_h4 + "\n\n" + interview_file_content += "#### " + interview_h4 + "\n\n" + elif title_size == "######": + interview_h6 = title_content + problem_ids = title_content.split('、') + if not problem_ids: + continue + + frame = pd.DataFrame(columns=['题号', '标题', '题解', '标签', '难度']) + frame_cout = 0 + for problem_id in problem_ids: + problems_set.add(problem_id) + problem_id_path = solotions_path + "/" + problem_id + ".md" + res = get_problem_id_row(problem_id_path, problem_id) + if res: + frame.loc[frame_cout] = res + frame_cout += 1 + table = gen_markdown_table(frame, False) + interview_h3_file_content += table + "\n\n" + interview_file_content += table + "\n\n" + + if interview_file_content: + with open(interview_list_path, 'w') as fi: + if "Interview-100-List.md" in interview_origin_list_path: + fi.write("# LeetCode 面试最常考 100 题(按分类排序)\n\n") + elif "Interview-200-List.md" in interview_origin_list_path: + fi.write("# LeetCode 面试最常考 200 题(按分类排序)\n\n") + fi.write(interview_file_content) + fi.write("\n## 参考资料\n") + fi.write("\n- 【清单】[CodeTop 企业题库](https://codetop.cc/home)\n") + fi.close() + + print("Total Problems Count: " + str(len(problems_set))) + print(sorted(list(problems_set))) + print("Create Interview List Success") # 根据本地题解目录,获取对应题目 id 编号对应的行 def get_problem_id_row(problem_id_path, problem_id): diff --git a/Contents/00.Introduction/04.Solutions-List.md b/Contents/00.Introduction/04.Solutions-List.md index 3b8a3200..e9ba9b35 100644 --- a/Contents/00.Introduction/04.Solutions-List.md +++ b/Contents/00.Introduction/04.Solutions-List.md @@ -1,4 +1,4 @@ -# LeetCode 题解(已完成 707 道) +# LeetCode 题解(已完成 708 道) | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | @@ -246,6 +246,7 @@ | 0386 | [字典序排数](https://leetcode.cn/problems/lexicographical-numbers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0386.%20%E5%AD%97%E5%85%B8%E5%BA%8F%E6%8E%92%E6%95%B0.md) | 深度优先搜索、字典树 | 中等 | | 0387 | [字符串中的第一个唯一字符](https://leetcode.cn/problems/first-unique-character-in-a-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0387.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%94%AF%E4%B8%80%E5%AD%97%E7%AC%A6.md) | 字符串、哈希表 | 简单 | | 0389 | [找不同](https://leetcode.cn/problems/find-the-difference/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0389.%20%E6%89%BE%E4%B8%8D%E5%90%8C.md) | 位运算、哈希表 | 简单 | +| 0391 | [完美矩形](https://leetcode.cn/problems/perfect-rectangle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0391.%20%E5%AE%8C%E7%BE%8E%E7%9F%A9%E5%BD%A2.md) | 数组、扫描线 | 困难 | | 0392 | [判断子序列](https://leetcode.cn/problems/is-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0392.%20%E5%88%A4%E6%96%AD%E5%AD%90%E5%BA%8F%E5%88%97.md) | 双指针、字符串、动态规划 | 简单 | | 0394 | [字符串解码](https://leetcode.cn/problems/decode-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0394.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%A7%A3%E7%A0%81.md) | 栈、深度优先搜索 | 中等 | | 0395 | [至少有 K 个重复字符的最长子串](https://leetcode.cn/problems/longest-substring-with-at-least-k-repeating-characters/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0395.%20%E8%87%B3%E5%B0%91%E6%9C%89%20K%20%E4%B8%AA%E9%87%8D%E5%A4%8D%E5%AD%97%E7%AC%A6%E7%9A%84%E6%9C%80%E9%95%BF%E5%AD%90%E4%B8%B2.md) | 哈希表、字符串、分治、滑动窗口 | 中等 | diff --git a/Contents/00.Introduction/05.Categories-List.md b/Contents/00.Introduction/05.Categories-List.md index 9c7e39a6..1e3dd586 100644 --- a/Contents/00.Introduction/05.Categories-List.md +++ b/Contents/00.Introduction/05.Categories-List.md @@ -1,3 +1,5 @@ +# LeetCode 题解(按分类排序,推荐刷题列表 ★★★) + ## 01. 数组 ### 数组基础题目 @@ -489,7 +491,7 @@ | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | | 0218 | [天际线问题](https://leetcode.cn/problems/the-skyline-problem/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0218.%20%E5%A4%A9%E9%99%85%E7%BA%BF%E9%97%AE%E9%A2%98.md) | 树状数组、线段树、数组、分治、有序集合、扫描线、堆(优先队列) | 困难 | -| 0391 | 完美矩形 | | | | +| 0391 | [完美矩形](https://leetcode.cn/problems/perfect-rectangle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0391.%20%E5%AE%8C%E7%BE%8E%E7%9F%A9%E5%BD%A2.md) | 数组、扫描线 | 困难 | | 0850 | 矩形面积 II | | | | ### 树状数组题目 diff --git a/Contents/00.Introduction/06.Interview-100-List.md b/Contents/00.Introduction/06.Interview-100-List.md new file mode 100644 index 00000000..701b11a0 --- /dev/null +++ b/Contents/00.Introduction/06.Interview-100-List.md @@ -0,0 +1,382 @@ +# LeetCode 面试最常考 100 题(按分类排序) + +## 01. 数组 + +### 数组基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0054 | [螺旋矩阵](https://leetcode.cn/problems/spiral-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0054.%20%E8%9E%BA%E6%97%8B%E7%9F%A9%E9%98%B5.md) | 数组 | 中等 | +| 0048 | [旋转图像](https://leetcode.cn/problems/rotate-image/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0048.%20%E6%97%8B%E8%BD%AC%E5%9B%BE%E5%83%8F.md) | 数组 | 中等 | + +### 排序算法题目 + +#### 选择排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0215 | [数组中的第K个最大元素](https://leetcode.cn/problems/kth-largest-element-in-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0215.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E7%AC%ACK%E4%B8%AA%E6%9C%80%E5%A4%A7%E5%85%83%E7%B4%A0.md) | 数组、堆排序 | 中等 | + +#### 希尔排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | + +#### 归并排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | +| 0088 | [合并两个有序数组](https://leetcode.cn/problems/merge-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0088.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、双指针 | 简单 | + +#### 快速排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | +| 0169 | [多数元素](https://leetcode.cn/problems/majority-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0169.%20%E5%A4%9A%E6%95%B0%E5%85%83%E7%B4%A0.md) | 数组、哈希表 | 简单 | + +#### 堆排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | +| 0215 | [数组中的第K个最大元素](https://leetcode.cn/problems/kth-largest-element-in-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0215.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E7%AC%ACK%E4%B8%AA%E6%9C%80%E5%A4%A7%E5%85%83%E7%B4%A0.md) | 数组、堆排序 | 中等 | + +#### 计数排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | + +#### 桶排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | + +#### 其他排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | +| 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | +| 0179 | [最大数](https://leetcode.cn/problems/largest-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0179.%20%E6%9C%80%E5%A4%A7%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | + +### 二分查找题目 + +#### 二分下标题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0704 | [二分查找](https://leetcode.cn/problems/binary-search/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0704.%20%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE.md) | 二分查找 | 简单 | +| 0034 | [在排序数组中查找元素的第一个和最后一个位置](https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0034.%20%E5%9C%A8%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E6%9F%A5%E6%89%BE%E5%85%83%E7%B4%A0%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%92%8C%E6%9C%80%E5%90%8E%E4%B8%80%E4%B8%AA%E4%BD%8D%E7%BD%AE.md) | 数组、二分查找 | 中等 | +| 0153 | [寻找旋转排序数组中的最小值](https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0153.%20%E5%AF%BB%E6%89%BE%E6%97%8B%E8%BD%AC%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E6%9C%80%E5%B0%8F%E5%80%BC.md) | 数组、二分查找 | 中等 | +| 0033 | [搜索旋转排序数组](https://leetcode.cn/problems/search-in-rotated-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0033.%20%E6%90%9C%E7%B4%A2%E6%97%8B%E8%BD%AC%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、二分查找 | 中等 | +| 0162 | [寻找峰值](https://leetcode.cn/problems/find-peak-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0162.%20%E5%AF%BB%E6%89%BE%E5%B3%B0%E5%80%BC.md) | 数组、二分查找 | 中等 | +| 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | +| 0240 | [搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0240.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5%20II.md) | 二分查找、分治算法 | 中等 | + +#### 二分答案题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0069 | [x 的平方根](https://leetcode.cn/problems/sqrtx/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0069.%20x%20%E7%9A%84%E5%B9%B3%E6%96%B9%E6%A0%B9.md) | 数学、二分查找 | 简单 | + +### 双指针题目 + +#### 对撞指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0015 | [三数之和](https://leetcode.cn/problems/3sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0015.%20%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、双指针 | 中等 | + +#### 快慢指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0283 | [移动零](https://leetcode.cn/problems/move-zeroes/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0283.%20%E7%A7%BB%E5%8A%A8%E9%9B%B6.md) | 数组、双指针 | 简单 | +| 0088 | [合并两个有序数组](https://leetcode.cn/problems/merge-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0088.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、双指针 | 简单 | + +#### 分离双指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0415 | [字符串相加](https://leetcode.cn/problems/add-strings/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0415.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9B%B8%E5%8A%A0.md) | 字符串、大数加法 | 简单 | + +### 滑动窗口题目 + +#### 固定长度窗口题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0239 | [滑动窗口最大值](https://leetcode.cn/problems/sliding-window-maximum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0239.%20%E6%BB%91%E5%8A%A8%E7%AA%97%E5%8F%A3%E6%9C%80%E5%A4%A7%E5%80%BC.md) | 队列,数组、滑动窗口、单调队列、堆(优先队列) | 困难 | + +#### 不定长度窗口题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0003 | [无重复字符的最长子串](https://leetcode.cn/problems/longest-substring-without-repeating-characters/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0003.%20%E6%97%A0%E9%87%8D%E5%A4%8D%E5%AD%97%E7%AC%A6%E7%9A%84%E6%9C%80%E9%95%BF%E5%AD%90%E4%B8%B2.md) | 字符串、哈希表、双指针、字符串、滑动窗口 | 中等 | +| 0076 | [最小覆盖子串](https://leetcode.cn/problems/minimum-window-substring/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0076.%20%E6%9C%80%E5%B0%8F%E8%A6%86%E7%9B%96%E5%AD%90%E4%B8%B2.md) | 哈希表、字符串、滑动窗口 | 困难 | +| 0718 | [最长重复子数组](https://leetcode.cn/problems/maximum-length-of-repeated-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0718.%20%E6%9C%80%E9%95%BF%E9%87%8D%E5%A4%8D%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、二分查找、动态规划、滑动窗口、哈希函数、滚动哈希 | 中等 | + +## 02. 链表 + +### 链表经典题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0083 | [删除排序链表中的重复元素](https://leetcode.cn/problems/remove-duplicates-from-sorted-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0083.%20%E5%88%A0%E9%99%A4%E6%8E%92%E5%BA%8F%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E5%85%83%E7%B4%A0.md) | 链表 | 简单 | +| 0082 | 删除排序链表中的重复元素 II | | | | +| 0206 | [反转链表](https://leetcode.cn/problems/reverse-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0206.%20%E5%8F%8D%E8%BD%AC%E9%93%BE%E8%A1%A8.md) | 链表 | 简单 | +| 0092 | 反转链表 II | | | | +| 0025 | K 个一组翻转链表 | | | | +| 0234 | [回文链表](https://leetcode.cn/problems/palindrome-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0234.%20%E5%9B%9E%E6%96%87%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 简单 | + +### 链表排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0148 | [排序链表](https://leetcode.cn/problems/sort-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0148.%20%E6%8E%92%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、双指针、分治、排序、归并排序 | 中等 | +| 0021 | [合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0021.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 递归、链表 | 简单 | +| 0023 | [合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0023.%20%E5%90%88%E5%B9%B6K%E4%B8%AA%E5%8D%87%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、分治、堆(优先队列)、归并排序 | 困难 | + +### 链表双指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0141 | [环形链表](https://leetcode.cn/problems/linked-list-cycle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0141.%20%E7%8E%AF%E5%BD%A2%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 简单 | +| 0142 | [环形链表 II](https://leetcode.cn/problems/linked-list-cycle-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0142.%20%E7%8E%AF%E5%BD%A2%E9%93%BE%E8%A1%A8%20II.md) | 链表、双指针 | 中等 | +| 0160 | [相交链表](https://leetcode.cn/problems/intersection-of-two-linked-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0160.%20%E7%9B%B8%E4%BA%A4%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 简单 | +| 0019 | [删除链表的倒数第 N 个结点](https://leetcode.cn/problems/remove-nth-node-from-end-of-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0019.%20%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%AC%20N%20%E4%B8%AA%E7%BB%93%E7%82%B9.md) | 链表、双指针 | 中等 | +| 剑指 Offer 22 | [链表中倒数第k个节点](https://leetcode.cn/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2022.%20%E9%93%BE%E8%A1%A8%E4%B8%AD%E5%80%92%E6%95%B0%E7%AC%ACk%E4%B8%AA%E8%8A%82%E7%82%B9.md) | 链表、双指针 | 简单 | +| 0143 | [重排链表](https://leetcode.cn/problems/reorder-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0143.%20%E9%87%8D%E6%8E%92%E9%93%BE%E8%A1%A8.md) | 栈、递归、链表、双指针 | 中等 | +| 0002 | [两数相加](https://leetcode.cn/problems/add-two-numbers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0002.%20%E4%B8%A4%E6%95%B0%E7%9B%B8%E5%8A%A0.md) | 递归、链表、数学 | 中等 | + +## 03. 堆栈 + +### 堆栈基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0155 | [最小栈](https://leetcode.cn/problems/min-stack/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0155.%20%E6%9C%80%E5%B0%8F%E6%A0%88.md) | 栈、设计 | 简单 | +| 0020 | [有效的括号](https://leetcode.cn/problems/valid-parentheses/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0020.%20%E6%9C%89%E6%95%88%E7%9A%84%E6%8B%AC%E5%8F%B7.md) | 栈、字符串 | 简单 | +| 0227 | [基本计算器 II](https://leetcode.cn/problems/basic-calculator-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0227.%20%E5%9F%BA%E6%9C%AC%E8%AE%A1%E7%AE%97%E5%99%A8%20II.md) | 栈、字符串 | 中等 | +| 0232 | [用栈实现队列](https://leetcode.cn/problems/implement-queue-using-stacks/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0232.%20%E7%94%A8%E6%A0%88%E5%AE%9E%E7%8E%B0%E9%98%9F%E5%88%97.md) | 栈、设计 | 简单 | +| 0394 | [字符串解码](https://leetcode.cn/problems/decode-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0394.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%A7%A3%E7%A0%81.md) | 栈、深度优先搜索 | 中等 | +| 0032 | 最长有效括号 | | | | + +### 单调栈 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0042 | [接雨水](https://leetcode.cn/problems/trapping-rain-water/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0042.%20%E6%8E%A5%E9%9B%A8%E6%B0%B4.md) | 栈、数组、双指针、动态规划、单调栈 | 困难 | + +## 04. 队列 + +### 队列基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0225 | [用队列实现栈](https://leetcode.cn/problems/implement-stack-using-queues/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0225.%20%E7%94%A8%E9%98%9F%E5%88%97%E5%AE%9E%E7%8E%B0%E6%A0%88.md) | 栈、设计 | 简单 | + +### 优先队列题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0023 | [合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0023.%20%E5%90%88%E5%B9%B6K%E4%B8%AA%E5%8D%87%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、分治、堆(优先队列)、归并排序 | 困难 | +| 0239 | [滑动窗口最大值](https://leetcode.cn/problems/sliding-window-maximum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0239.%20%E6%BB%91%E5%8A%A8%E7%AA%97%E5%8F%A3%E6%9C%80%E5%A4%A7%E5%80%BC.md) | 队列,数组、滑动窗口、单调队列、堆(优先队列) | 困难 | + +## 05. 哈希表 + +### 哈希表题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0001 | [两数之和](https://leetcode.cn/problems/two-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0001.%20%E4%B8%A4%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、哈希表 | 简单 | +| 0015 | [三数之和](https://leetcode.cn/problems/3sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0015.%20%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、双指针 | 中等 | +| 0041 | [缺失的第一个正数](https://leetcode.cn/problems/first-missing-positive/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0041.%20%E7%BC%BA%E5%A4%B1%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E6%AD%A3%E6%95%B0.md) | 数组、哈希表 | 困难 | +| 0128 | [最长连续序列](https://leetcode.cn/problems/longest-consecutive-sequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0128.%20%E6%9C%80%E9%95%BF%E8%BF%9E%E7%BB%AD%E5%BA%8F%E5%88%97.md) | 并查集、数组、哈希表 | 中等 | +| 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | + +## 06. 字符串 + +### 字符串基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0003 | [无重复字符的最长子串](https://leetcode.cn/problems/longest-substring-without-repeating-characters/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0003.%20%E6%97%A0%E9%87%8D%E5%A4%8D%E5%AD%97%E7%AC%A6%E7%9A%84%E6%9C%80%E9%95%BF%E5%AD%90%E4%B8%B2.md) | 字符串、哈希表、双指针、字符串、滑动窗口 | 中等 | +| 0005 | [最长回文子串](https://leetcode.cn/problems/longest-palindromic-substring/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0005.%20%E6%9C%80%E9%95%BF%E5%9B%9E%E6%96%87%E5%AD%90%E4%B8%B2.md) | 字符串、动态规划 | 中等 | +| 0415 | [字符串相加](https://leetcode.cn/problems/add-strings/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0415.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9B%B8%E5%8A%A0.md) | 字符串、大数加法 | 简单 | +| 0151 | [颠倒字符串中的单词](https://leetcode.cn/problems/reverse-words-in-a-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0151.%20%E9%A2%A0%E5%80%92%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E7%9A%84%E5%8D%95%E8%AF%8D.md) | 双指针、字符串 | 中等 | +| 0043 | [字符串相乘](https://leetcode.cn/problems/multiply-strings/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0043.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9B%B8%E4%B9%98.md) | 数学、字符串、模拟 | 中等 | +| 0014 | [最长公共前缀](https://leetcode.cn/problems/longest-common-prefix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0014.%20%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%89%8D%E7%BC%80.md) | 字符串 | 简单 | + +## 07. 树 + +### 二叉树的遍历题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0144 | [二叉树的前序遍历](https://leetcode.cn/problems/binary-tree-preorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0144.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树 | 中等 | +| 0094 | [二叉树的中序遍历](https://leetcode.cn/problems/binary-tree-inorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0094.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树、哈希表 | 简单 | +| 0102 | [二叉树的层序遍历](https://leetcode.cn/problems/binary-tree-level-order-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0102.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%B1%82%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 树、广度优先搜索 | 中等 | +| 0103 | [二叉树的锯齿形层序遍历](https://leetcode.cn/problems/binary-tree-zigzag-level-order-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0103.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E9%94%AF%E9%BD%BF%E5%BD%A2%E5%B1%82%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 树、广度优先搜索、二叉树 | 中等 | +| 0236 | [二叉树的最近公共祖先](https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0236.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88.md) | 树 | 中等 | +| 0104 | [二叉树的最大深度](https://leetcode.cn/problems/maximum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0104.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%A4%A7%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、递归 | 简单 | +| 0112 | [路径总和](https://leetcode.cn/problems/path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0112.%20%E8%B7%AF%E5%BE%84%E6%80%BB%E5%92%8C.md) | 树、深度优先搜索 | 简单 | +| 0113 | [路径总和 II](https://leetcode.cn/problems/path-sum-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0113.%20%E8%B7%AF%E5%BE%84%E6%80%BB%E5%92%8C%20II.md) | 树、深度优先搜索、回溯、二叉树 | 中等 | +| 0101 | [对称二叉树](https://leetcode.cn/problems/symmetric-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0101.%20%E5%AF%B9%E7%A7%B0%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、深度优先搜索、广度优先搜索 | 简单 | +| 0124 | [二叉树中的最大路径和](https://leetcode.cn/problems/binary-tree-maximum-path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0124.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 树、深度优先搜索、动态规划、二叉树 | 困难 | +| 0199 | [二叉树的右视图](https://leetcode.cn/problems/binary-tree-right-side-view/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0199.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%8F%B3%E8%A7%86%E5%9B%BE.md) | 树、深度优先搜索、广度优先搜索、递归、队列 | 中等 | +| 0226 | [翻转二叉树](https://leetcode.cn/problems/invert-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0226.%20%E7%BF%BB%E8%BD%AC%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、递归 | 简单 | + +### 二叉树的还原题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0105 | [从前序与中序遍历序列构造二叉树](https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0105.%20%E4%BB%8E%E5%89%8D%E5%BA%8F%E4%B8%8E%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86%E5%BA%8F%E5%88%97%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、数组、哈希表、分治、二叉树 | 中等 | + +### 二叉搜索树题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0098 | [验证二叉搜索树](https://leetcode.cn/problems/validate-binary-search-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0098.%20%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.md) | 树、深度优先搜索、递归 | 中等 | +| 0110 | [平衡二叉树](https://leetcode.cn/problems/balanced-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0110.%20%E5%B9%B3%E8%A1%A1%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、深度优先搜索、递归 | 简单 | + +### 并查集题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0128 | [最长连续序列](https://leetcode.cn/problems/longest-consecutive-sequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0128.%20%E6%9C%80%E9%95%BF%E8%BF%9E%E7%BB%AD%E5%BA%8F%E5%88%97.md) | 并查集、数组、哈希表 | 中等 | + +## 08. 图论 + +### 图的深度优先搜索题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0200 | [岛屿数量](https://leetcode.cn/problems/number-of-islands/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0200.%20%E5%B2%9B%E5%B1%BF%E6%95%B0%E9%87%8F.md) | 搜索 | 中等 | +| 0695 | [岛屿的最大面积](https://leetcode.cn/problems/max-area-of-island/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0695.%20%E5%B2%9B%E5%B1%BF%E7%9A%84%E6%9C%80%E5%A4%A7%E9%9D%A2%E7%A7%AF.md) | 搜索 | 中等 | +| 0144 | [二叉树的前序遍历](https://leetcode.cn/problems/binary-tree-preorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0144.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树 | 中等 | +| 0094 | [二叉树的中序遍历](https://leetcode.cn/problems/binary-tree-inorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0094.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树、哈希表 | 简单 | +| 0129 | [求根节点到叶节点数字之和](https://leetcode.cn/problems/sum-root-to-leaf-numbers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0129.%20%E6%B1%82%E6%A0%B9%E8%8A%82%E7%82%B9%E5%88%B0%E5%8F%B6%E8%8A%82%E7%82%B9%E6%95%B0%E5%AD%97%E4%B9%8B%E5%92%8C.md) | 树、深度优先搜索、二叉树 | 中等 | +| 0124 | [二叉树中的最大路径和](https://leetcode.cn/problems/binary-tree-maximum-path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0124.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 树、深度优先搜索、动态规划、二叉树 | 困难 | +| 0199 | [二叉树的右视图](https://leetcode.cn/problems/binary-tree-right-side-view/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0199.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%8F%B3%E8%A7%86%E5%9B%BE.md) | 树、深度优先搜索、广度优先搜索、递归、队列 | 中等 | +| 0543 | [二叉树的直径](https://leetcode.cn/problems/diameter-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0543.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E7%9B%B4%E5%BE%84.md) | 二叉树 | 简单 | +| 0662 | 二叉树最大宽度 | | | | + +### 图的广度优先搜索题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0200 | [岛屿数量](https://leetcode.cn/problems/number-of-islands/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0200.%20%E5%B2%9B%E5%B1%BF%E6%95%B0%E9%87%8F.md) | 搜索 | 中等 | +| 0322 | [零钱兑换](https://leetcode.cn/problems/coin-change/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0322.%20%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2.md) | 动态规划 | 中等 | +| 0199 | [二叉树的右视图](https://leetcode.cn/problems/binary-tree-right-side-view/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0199.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%8F%B3%E8%A7%86%E5%9B%BE.md) | 树、深度优先搜索、广度优先搜索、递归、队列 | 中等 | +| 0662 | 二叉树最大宽度 | | | | + +## 09. 基础算法 + +### 枚举算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0001 | [两数之和](https://leetcode.cn/problems/two-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0001.%20%E4%B8%A4%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、哈希表 | 简单 | +| 0078 | [子集](https://leetcode.cn/problems/subsets/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0078.%20%E5%AD%90%E9%9B%86.md) | 位运算、数组、回溯算法 | 中等 | +| 0221 | 最大正方形 | | | | + +### 递归算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0024 | [两两交换链表中的节点](https://leetcode.cn/problems/swap-nodes-in-pairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0024.%20%E4%B8%A4%E4%B8%A4%E4%BA%A4%E6%8D%A2%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.md) | 递归、链表 | 中等 | +| 0206 | [反转链表](https://leetcode.cn/problems/reverse-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0206.%20%E5%8F%8D%E8%BD%AC%E9%93%BE%E8%A1%A8.md) | 链表 | 简单 | +| 0092 | 反转链表 II | | | | +| 0021 | [合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0021.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 递归、链表 | 简单 | +| 0070 | [爬楼梯](https://leetcode.cn/problems/climbing-stairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0070.%20%E7%88%AC%E6%A5%BC%E6%A2%AF.md) | 动态规划 | 简单 | +| 0104 | [二叉树的最大深度](https://leetcode.cn/problems/maximum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0104.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%A4%A7%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、递归 | 简单 | +| 0124 | [二叉树中的最大路径和](https://leetcode.cn/problems/binary-tree-maximum-path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0124.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 树、深度优先搜索、动态规划、二叉树 | 困难 | +| 0226 | [翻转二叉树](https://leetcode.cn/problems/invert-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0226.%20%E7%BF%BB%E8%BD%AC%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、递归 | 简单 | + +### 分治算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0053 | [最大子数组和](https://leetcode.cn/problems/maximum-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0053.%20%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84%E5%92%8C.md) | 数组、分治算法、动态规划 | 简单 | +| 0023 | [合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0023.%20%E5%90%88%E5%B9%B6K%E4%B8%AA%E5%8D%87%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、分治、堆(优先队列)、归并排序 | 困难 | +| 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | +| 0169 | [多数元素](https://leetcode.cn/problems/majority-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0169.%20%E5%A4%9A%E6%95%B0%E5%85%83%E7%B4%A0.md) | 数组、哈希表 | 简单 | +| 0014 | [最长公共前缀](https://leetcode.cn/problems/longest-common-prefix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0014.%20%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%89%8D%E7%BC%80.md) | 字符串 | 简单 | + +### 回溯算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0046 | [全排列](https://leetcode.cn/problems/permutations/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0046.%20%E5%85%A8%E6%8E%92%E5%88%97.md) | 回溯算法 | 中等 | +| 0022 | [括号生成](https://leetcode.cn/problems/generate-parentheses/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0022.%20%E6%8B%AC%E5%8F%B7%E7%94%9F%E6%88%90.md) | 字符串、回溯算法 | 中等 | +| 0078 | [子集](https://leetcode.cn/problems/subsets/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0078.%20%E5%AD%90%E9%9B%86.md) | 位运算、数组、回溯算法 | 中等 | +| 0039 | [组合总和](https://leetcode.cn/problems/combination-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0039.%20%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8C.md) | 数组、回溯 | 中等 | +| 0093 | [复原 IP 地址](https://leetcode.cn/problems/restore-ip-addresses/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0093.%20%E5%A4%8D%E5%8E%9F%20IP%20%E5%9C%B0%E5%9D%80.md) | 字符串、回溯 | 中等 | + +### 贪心算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0053 | [最大子数组和](https://leetcode.cn/problems/maximum-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0053.%20%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84%E5%92%8C.md) | 数组、分治算法、动态规划 | 简单 | +| 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | +| 0122 | [买卖股票的最佳时机 II](https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0122.%20%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA%20II.md) | 数组、贪心算法 | 简单 | + +### 位运算题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | + +## 10. 动态规划 + +### 动态规划题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0070 | [爬楼梯](https://leetcode.cn/problems/climbing-stairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0070.%20%E7%88%AC%E6%A5%BC%E6%A2%AF.md) | 动态规划 | 简单 | +| 0121 | [买卖股票的最佳时机](https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0121.%20%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA.md) | 数组、动态规划 | 简单 | +| 0322 | [零钱兑换](https://leetcode.cn/problems/coin-change/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0322.%20%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2.md) | 动态规划 | 中等 | +| 0300 | [最长递增子序列](https://leetcode.cn/problems/longest-increasing-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0300.%20%E6%9C%80%E9%95%BF%E9%80%92%E5%A2%9E%E5%AD%90%E5%BA%8F%E5%88%97.md) | 二分查找、动态规划 | 中等 | +| 1143 | [最长公共子序列](https://leetcode.cn/problems/longest-common-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1143.%20%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%AD%90%E5%BA%8F%E5%88%97.md) | 字符串、动态规划 | 中等 | +| 0718 | [最长重复子数组](https://leetcode.cn/problems/maximum-length-of-repeated-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0718.%20%E6%9C%80%E9%95%BF%E9%87%8D%E5%A4%8D%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、二分查找、动态规划、滑动窗口、哈希函数、滚动哈希 | 中等 | +| 0064 | 最小路径和 | | | | +| 0072 | [编辑距离](https://leetcode.cn/problems/edit-distance/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0072.%20%E7%BC%96%E8%BE%91%E8%B7%9D%E7%A6%BB.md) | 字符串、动态规划 | 困难 | +| 0032 | 最长有效括号 | | | | +| 0221 | 最大正方形 | | | | +| 0062 | [不同路径](https://leetcode.cn/problems/unique-paths/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0062.%20%E4%B8%8D%E5%90%8C%E8%B7%AF%E5%BE%84.md) | 数组、动态规划 | 中等 | +| 0152 | [乘积最大子数组](https://leetcode.cn/problems/maximum-product-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0152.%20%E4%B9%98%E7%A7%AF%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、动态规划 | 中等 | +| 0198 | [打家劫舍](https://leetcode.cn/problems/house-robber/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0198.%20%E6%89%93%E5%AE%B6%E5%8A%AB%E8%88%8D.md) | 动态规划 | 中等 | + +## 11. 补充题目 + +#### 设计数据结构题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0146 | LRU 缓存 | | | | + +#### 模拟题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0008 | [字符串转换整数 (atoi)](https://leetcode.cn/problems/string-to-integer-atoi/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0008.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E6%8D%A2%E6%95%B4%E6%95%B0%20%28atoi%29.md) | 数学、字符串 | 中等 | +| 0165 | 比较版本号 | | | | +| 0468 | 验证IP地址 | | | | + +#### 思维锻炼题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0031 | 下一个排列 | | | | +| 0470 | 用 Rand7() 实现 Rand10() | | | | + + +## 参考资料 + +- 【清单】[CodeTop 企业题库](https://codetop.cc/home) diff --git a/Contents/00.Introduction/07.Interview-200-List.md b/Contents/00.Introduction/07.Interview-200-List.md new file mode 100644 index 00000000..12cc8aa0 --- /dev/null +++ b/Contents/00.Introduction/07.Interview-200-List.md @@ -0,0 +1,551 @@ +# LeetCode 面试最常考 200 题(按分类排序) + +## 01. 数组 + +### 数组基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0189 | [轮转数组](https://leetcode.cn/problems/rotate-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0189.%20%E8%BD%AE%E8%BD%AC%E6%95%B0%E7%BB%84.md) | 数组 | 中等 | +| 0498 | [对角线遍历](https://leetcode.cn/problems/diagonal-traverse/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0498.%20%E5%AF%B9%E8%A7%92%E7%BA%BF%E9%81%8D%E5%8E%86.md) | 数组、矩阵、模拟 | 中等 | +| 0054 | [螺旋矩阵](https://leetcode.cn/problems/spiral-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0054.%20%E8%9E%BA%E6%97%8B%E7%9F%A9%E9%98%B5.md) | 数组 | 中等 | +| 0059 | [螺旋矩阵 II](https://leetcode.cn/problems/spiral-matrix-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0059.%20%E8%9E%BA%E6%97%8B%E7%9F%A9%E9%98%B5%20II.md) | 数组、矩阵、模拟 | 中等 | +| 0048 | [旋转图像](https://leetcode.cn/problems/rotate-image/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0048.%20%E6%97%8B%E8%BD%AC%E5%9B%BE%E5%83%8F.md) | 数组 | 中等 | + +### 排序算法题目 + +#### 冒泡排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0283 | [移动零](https://leetcode.cn/problems/move-zeroes/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0283.%20%E7%A7%BB%E5%8A%A8%E9%9B%B6.md) | 数组、双指针 | 简单 | + +#### 选择排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0215 | [数组中的第K个最大元素](https://leetcode.cn/problems/kth-largest-element-in-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0215.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E7%AC%ACK%E4%B8%AA%E6%9C%80%E5%A4%A7%E5%85%83%E7%B4%A0.md) | 数组、堆排序 | 中等 | + +#### 插入排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0075 | [颜色分类](https://leetcode.cn/problems/sort-colors/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0075.%20%E9%A2%9C%E8%89%B2%E5%88%86%E7%B1%BB.md) | 数组、排序、双指针 | 中等 | + +#### 希尔排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | + +#### 归并排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | +| 0088 | [合并两个有序数组](https://leetcode.cn/problems/merge-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0088.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、双指针 | 简单 | +| 剑指 Offer 51 | [数组中的逆序对](https://leetcode.cn/problems/shu-zu-zhong-de-ni-xu-dui-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2051.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E9%80%86%E5%BA%8F%E5%AF%B9.md) | 树状数组、线段树、数组、二分查找、分治、有序集合、归并排序 | 困难 | + +#### 快速排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | +| 0169 | [多数元素](https://leetcode.cn/problems/majority-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0169.%20%E5%A4%9A%E6%95%B0%E5%85%83%E7%B4%A0.md) | 数组、哈希表 | 简单 | + +#### 堆排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | +| 0215 | [数组中的第K个最大元素](https://leetcode.cn/problems/kth-largest-element-in-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0215.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E7%AC%ACK%E4%B8%AA%E6%9C%80%E5%A4%A7%E5%85%83%E7%B4%A0.md) | 数组、堆排序 | 中等 | +| 剑指 Offer 40 | [最小的k个数](https://leetcode.cn/problems/zui-xiao-de-kge-shu-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2040.%20%E6%9C%80%E5%B0%8F%E7%9A%84k%E4%B8%AA%E6%95%B0.md) | 数组、分治、快速选择、排序、堆(优先队列) | 简单 | + +#### 计数排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | + +#### 桶排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0912 | [排序数组](https://leetcode.cn/problems/sort-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0912.%20%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、分治、桶排序、计数排序、基数排序、排序、堆(优先队列) | 中等 | + +#### 基数排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0164 | [最大间距](https://leetcode.cn/problems/maximum-gap/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0164.%20%E6%9C%80%E5%A4%A7%E9%97%B4%E8%B7%9D.md) | 数组、桶排序、基数排序、排序 | 困难 | + +#### 其他排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | +| 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | +| 0179 | [最大数](https://leetcode.cn/problems/largest-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0179.%20%E6%9C%80%E5%A4%A7%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | +| 0384 | 打乱数组 | | | | +| 剑指 Offer 45 | [把数组排成最小的数](https://leetcode.cn/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2045.%20%E6%8A%8A%E6%95%B0%E7%BB%84%E6%8E%92%E6%88%90%E6%9C%80%E5%B0%8F%E7%9A%84%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | + +### 二分查找题目 + +#### 二分下标题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0704 | [二分查找](https://leetcode.cn/problems/binary-search/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0704.%20%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE.md) | 二分查找 | 简单 | +| 0034 | [在排序数组中查找元素的第一个和最后一个位置](https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0034.%20%E5%9C%A8%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E6%9F%A5%E6%89%BE%E5%85%83%E7%B4%A0%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%92%8C%E6%9C%80%E5%90%8E%E4%B8%80%E4%B8%AA%E4%BD%8D%E7%BD%AE.md) | 数组、二分查找 | 中等 | +| 0153 | [寻找旋转排序数组中的最小值](https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0153.%20%E5%AF%BB%E6%89%BE%E6%97%8B%E8%BD%AC%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E6%9C%80%E5%B0%8F%E5%80%BC.md) | 数组、二分查找 | 中等 | +| 0154 | [寻找旋转排序数组中的最小值 II](https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0154.%20%E5%AF%BB%E6%89%BE%E6%97%8B%E8%BD%AC%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E6%9C%80%E5%B0%8F%E5%80%BC%20II.md) | 数组、二分查找 | 困难 | +| 0033 | [搜索旋转排序数组](https://leetcode.cn/problems/search-in-rotated-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0033.%20%E6%90%9C%E7%B4%A2%E6%97%8B%E8%BD%AC%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、二分查找 | 中等 | +| 0162 | [寻找峰值](https://leetcode.cn/problems/find-peak-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0162.%20%E5%AF%BB%E6%89%BE%E5%B3%B0%E5%80%BC.md) | 数组、二分查找 | 中等 | +| 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | +| 0074 | 搜索二维矩阵 | | | | +| 0240 | [搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0240.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5%20II.md) | 二分查找、分治算法 | 中等 | + +#### 二分答案题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0069 | [x 的平方根](https://leetcode.cn/problems/sqrtx/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0069.%20x%20%E7%9A%84%E5%B9%B3%E6%96%B9%E6%A0%B9.md) | 数学、二分查找 | 简单 | +| 0287 | [寻找重复数](https://leetcode.cn/problems/find-the-duplicate-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0287.%20%E5%AF%BB%E6%89%BE%E9%87%8D%E5%A4%8D%E6%95%B0.md) | 数组、双指针、二分查找 | 中等 | +| 0050 | [Pow(x, n)](https://leetcode.cn/problems/powx-n/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0050.%20Pow%28x%2C%20n%29.md) | 数学、二分查找 | 中等 | +| 0400 | [第 N 位数字](https://leetcode.cn/problems/nth-digit/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0400.%20%E7%AC%AC%20N%20%E4%BD%8D%E6%95%B0%E5%AD%97.md) | 数学、二分查找 | 中等 | + +#### 复杂的二分查找问题 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0209 | [长度最小的子数组](https://leetcode.cn/problems/minimum-size-subarray-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0209.%20%E9%95%BF%E5%BA%A6%E6%9C%80%E5%B0%8F%E7%9A%84%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、双指针、二分查找 | 中等 | +| 0349 | [两个数组的交集](https://leetcode.cn/problems/intersection-of-two-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0349.%20%E4%B8%A4%E4%B8%AA%E6%95%B0%E7%BB%84%E7%9A%84%E4%BA%A4%E9%9B%86.md) | 数组、哈希表 | 简单 | + +### 双指针题目 + +#### 对撞指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0611 | [有效三角形的个数](https://leetcode.cn/problems/valid-triangle-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0611.%20%E6%9C%89%E6%95%88%E4%B8%89%E8%A7%92%E5%BD%A2%E7%9A%84%E4%B8%AA%E6%95%B0.md) | 贪心、数组、双指针、二分查找、排序 | 中等 | +| 0015 | [三数之和](https://leetcode.cn/problems/3sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0015.%20%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、双指针 | 中等 | +| 0016 | [最接近的三数之和](https://leetcode.cn/problems/3sum-closest/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0016.%20%E6%9C%80%E6%8E%A5%E8%BF%91%E7%9A%84%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、双指针、排序 | 中等 | +| 0125 | [验证回文串](https://leetcode.cn/problems/valid-palindrome/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0125.%20%E9%AA%8C%E8%AF%81%E5%9B%9E%E6%96%87%E4%B8%B2.md) | 字符串、双指针 | 简单 | +| 0011 | [盛最多水的容器](https://leetcode.cn/problems/container-with-most-water/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0011.%20%E7%9B%9B%E6%9C%80%E5%A4%9A%E6%B0%B4%E7%9A%84%E5%AE%B9%E5%99%A8.md) | 贪心、数组、双指针 | 中等 | +| 0075 | [颜色分类](https://leetcode.cn/problems/sort-colors/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0075.%20%E9%A2%9C%E8%89%B2%E5%88%86%E7%B1%BB.md) | 数组、排序、双指针 | 中等 | +| 剑指 Offer 21 | [调整数组顺序使奇数位于偶数前面](https://leetcode.cn/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2021.%20%E8%B0%83%E6%95%B4%E6%95%B0%E7%BB%84%E9%A1%BA%E5%BA%8F%E4%BD%BF%E5%A5%87%E6%95%B0%E4%BD%8D%E4%BA%8E%E5%81%B6%E6%95%B0%E5%89%8D%E9%9D%A2.md) | 数组、双指针、排序 | 简单 | +| 0443 | 压缩字符串 | | | | + +#### 快慢指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0026 | [删除有序数组中的重复项](https://leetcode.cn/problems/remove-duplicates-from-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0026.%20%E5%88%A0%E9%99%A4%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E9%A1%B9.md) | 数组、双指针 | 简单 | +| 0283 | [移动零](https://leetcode.cn/problems/move-zeroes/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0283.%20%E7%A7%BB%E5%8A%A8%E9%9B%B6.md) | 数组、双指针 | 简单 | +| 0088 | [合并两个有序数组](https://leetcode.cn/problems/merge-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0088.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、双指针 | 简单 | + +#### 分离双指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0415 | [字符串相加](https://leetcode.cn/problems/add-strings/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0415.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9B%B8%E5%8A%A0.md) | 字符串、大数加法 | 简单 | + +### 滑动窗口题目 + +#### 固定长度窗口题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0239 | [滑动窗口最大值](https://leetcode.cn/problems/sliding-window-maximum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0239.%20%E6%BB%91%E5%8A%A8%E7%AA%97%E5%8F%A3%E6%9C%80%E5%A4%A7%E5%80%BC.md) | 队列,数组、滑动窗口、单调队列、堆(优先队列) | 困难 | + +#### 不定长度窗口题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0003 | [无重复字符的最长子串](https://leetcode.cn/problems/longest-substring-without-repeating-characters/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0003.%20%E6%97%A0%E9%87%8D%E5%A4%8D%E5%AD%97%E7%AC%A6%E7%9A%84%E6%9C%80%E9%95%BF%E5%AD%90%E4%B8%B2.md) | 字符串、哈希表、双指针、字符串、滑动窗口 | 中等 | +| 0076 | [最小覆盖子串](https://leetcode.cn/problems/minimum-window-substring/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0076.%20%E6%9C%80%E5%B0%8F%E8%A6%86%E7%9B%96%E5%AD%90%E4%B8%B2.md) | 哈希表、字符串、滑动窗口 | 困难 | +| 0718 | [最长重复子数组](https://leetcode.cn/problems/maximum-length-of-repeated-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0718.%20%E6%9C%80%E9%95%BF%E9%87%8D%E5%A4%8D%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、二分查找、动态规划、滑动窗口、哈希函数、滚动哈希 | 中等 | +| 0209 | [长度最小的子数组](https://leetcode.cn/problems/minimum-size-subarray-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0209.%20%E9%95%BF%E5%BA%A6%E6%9C%80%E5%B0%8F%E7%9A%84%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、双指针、二分查找 | 中等 | +| 0862 | 和至少为 K 的最短子数组 | | | | +| 1004 | [最大连续1的个数 III](https://leetcode.cn/problems/max-consecutive-ones-iii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1004.%20%E6%9C%80%E5%A4%A7%E8%BF%9E%E7%BB%AD1%E7%9A%84%E4%B8%AA%E6%95%B0%20III.md) | 双指针、滑动窗口 | 中等 | + +## 02. 链表 + +### 链表经典题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0083 | [删除排序链表中的重复元素](https://leetcode.cn/problems/remove-duplicates-from-sorted-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0083.%20%E5%88%A0%E9%99%A4%E6%8E%92%E5%BA%8F%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E5%85%83%E7%B4%A0.md) | 链表 | 简单 | +| 0082 | 删除排序链表中的重复元素 II | | | | +| 0206 | [反转链表](https://leetcode.cn/problems/reverse-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0206.%20%E5%8F%8D%E8%BD%AC%E9%93%BE%E8%A1%A8.md) | 链表 | 简单 | +| 0092 | 反转链表 II | | | | +| 0328 | [奇偶链表](https://leetcode.cn/problems/odd-even-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0328.%20%E5%A5%87%E5%81%B6%E9%93%BE%E8%A1%A8.md) | 链表 | 中等 | +| 0025 | K 个一组翻转链表 | | | | +| 0234 | [回文链表](https://leetcode.cn/problems/palindrome-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0234.%20%E5%9B%9E%E6%96%87%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 简单 | +| 0138 | [复制带随机指针的链表](https://leetcode.cn/problems/copy-list-with-random-pointer/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0138.%20%E5%A4%8D%E5%88%B6%E5%B8%A6%E9%9A%8F%E6%9C%BA%E6%8C%87%E9%92%88%E7%9A%84%E9%93%BE%E8%A1%A8.md) | 链表、哈希表 | 中等 | +| 0061 | [旋转链表](https://leetcode.cn/problems/rotate-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0061.%20%E6%97%8B%E8%BD%AC%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 中等 | + +### 链表排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0148 | [排序链表](https://leetcode.cn/problems/sort-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0148.%20%E6%8E%92%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、双指针、分治、排序、归并排序 | 中等 | +| 0021 | [合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0021.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 递归、链表 | 简单 | +| 0023 | [合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0023.%20%E5%90%88%E5%B9%B6K%E4%B8%AA%E5%8D%87%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、分治、堆(优先队列)、归并排序 | 困难 | + +### 链表双指针题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0141 | [环形链表](https://leetcode.cn/problems/linked-list-cycle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0141.%20%E7%8E%AF%E5%BD%A2%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 简单 | +| 0142 | [环形链表 II](https://leetcode.cn/problems/linked-list-cycle-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0142.%20%E7%8E%AF%E5%BD%A2%E9%93%BE%E8%A1%A8%20II.md) | 链表、双指针 | 中等 | +| 0160 | [相交链表](https://leetcode.cn/problems/intersection-of-two-linked-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0160.%20%E7%9B%B8%E4%BA%A4%E9%93%BE%E8%A1%A8.md) | 链表、双指针 | 简单 | +| 0019 | [删除链表的倒数第 N 个结点](https://leetcode.cn/problems/remove-nth-node-from-end-of-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0019.%20%E5%88%A0%E9%99%A4%E9%93%BE%E8%A1%A8%E7%9A%84%E5%80%92%E6%95%B0%E7%AC%AC%20N%20%E4%B8%AA%E7%BB%93%E7%82%B9.md) | 链表、双指针 | 中等 | +| 剑指 Offer 22 | [链表中倒数第k个节点](https://leetcode.cn/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2022.%20%E9%93%BE%E8%A1%A8%E4%B8%AD%E5%80%92%E6%95%B0%E7%AC%ACk%E4%B8%AA%E8%8A%82%E7%82%B9.md) | 链表、双指针 | 简单 | +| 0143 | [重排链表](https://leetcode.cn/problems/reorder-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0143.%20%E9%87%8D%E6%8E%92%E9%93%BE%E8%A1%A8.md) | 栈、递归、链表、双指针 | 中等 | +| 0002 | [两数相加](https://leetcode.cn/problems/add-two-numbers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0002.%20%E4%B8%A4%E6%95%B0%E7%9B%B8%E5%8A%A0.md) | 递归、链表、数学 | 中等 | +| 0445 | [两数相加 II](https://leetcode.cn/problems/add-two-numbers-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0445.%20%E4%B8%A4%E6%95%B0%E7%9B%B8%E5%8A%A0%20II.md) | 栈、链表、数学 | 中等 | + +## 03. 堆栈 + +### 堆栈基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 1047 | [删除字符串中的所有相邻重复项](https://leetcode.cn/problems/remove-all-adjacent-duplicates-in-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1047.%20%E5%88%A0%E9%99%A4%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E7%9A%84%E6%89%80%E6%9C%89%E7%9B%B8%E9%82%BB%E9%87%8D%E5%A4%8D%E9%A1%B9.md) | 字符串、栈 | 简单 | +| 0155 | [最小栈](https://leetcode.cn/problems/min-stack/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0155.%20%E6%9C%80%E5%B0%8F%E6%A0%88.md) | 栈、设计 | 简单 | +| 0020 | [有效的括号](https://leetcode.cn/problems/valid-parentheses/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0020.%20%E6%9C%89%E6%95%88%E7%9A%84%E6%8B%AC%E5%8F%B7.md) | 栈、字符串 | 简单 | +| 0224 | 基本计算器 | | | | +| 0227 | [基本计算器 II](https://leetcode.cn/problems/basic-calculator-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0227.%20%E5%9F%BA%E6%9C%AC%E8%AE%A1%E7%AE%97%E5%99%A8%20II.md) | 栈、字符串 | 中等 | +| 0232 | [用栈实现队列](https://leetcode.cn/problems/implement-queue-using-stacks/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0232.%20%E7%94%A8%E6%A0%88%E5%AE%9E%E7%8E%B0%E9%98%9F%E5%88%97.md) | 栈、设计 | 简单 | +| 剑指 Offer 09 | [用两个栈实现队列](https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2009.%20%E7%94%A8%E4%B8%A4%E4%B8%AA%E6%A0%88%E5%AE%9E%E7%8E%B0%E9%98%9F%E5%88%97.md) | 栈、设计、队列 | 简单 | +| 0394 | [字符串解码](https://leetcode.cn/problems/decode-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0394.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%A7%A3%E7%A0%81.md) | 栈、深度优先搜索 | 中等 | +| 0032 | 最长有效括号 | | | | +| 0739 | [每日温度](https://leetcode.cn/problems/daily-temperatures/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0739.%20%E6%AF%8F%E6%97%A5%E6%B8%A9%E5%BA%A6.md) | 栈、哈希表 | 中等 | +| 0071 | 简化路径 | | | | + +### 单调栈 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0739 | [每日温度](https://leetcode.cn/problems/daily-temperatures/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0739.%20%E6%AF%8F%E6%97%A5%E6%B8%A9%E5%BA%A6.md) | 栈、哈希表 | 中等 | +| 0503 | [下一个更大元素 II](https://leetcode.cn/problems/next-greater-element-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0503.%20%E4%B8%8B%E4%B8%80%E4%B8%AA%E6%9B%B4%E5%A4%A7%E5%85%83%E7%B4%A0%20II.md) | 栈、数组、单调栈 | 中等 | +| 0042 | [接雨水](https://leetcode.cn/problems/trapping-rain-water/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0042.%20%E6%8E%A5%E9%9B%A8%E6%B0%B4.md) | 栈、数组、双指针、动态规划、单调栈 | 困难 | +| 0085 | 最大矩形 | | | | + +## 04. 队列 + +### 队列基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0225 | [用队列实现栈](https://leetcode.cn/problems/implement-stack-using-queues/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0225.%20%E7%94%A8%E9%98%9F%E5%88%97%E5%AE%9E%E7%8E%B0%E6%A0%88.md) | 栈、设计 | 简单 | + +### 优先队列题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0295 | [数据流的中位数](https://leetcode.cn/problems/find-median-from-data-stream/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0295.%20%E6%95%B0%E6%8D%AE%E6%B5%81%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 设计、双指针、数据流、排序、堆(优先队列) | 困难 | +| 0347 | [前 K 个高频元素](https://leetcode.cn/problems/top-k-frequent-elements/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0347.%20%E5%89%8D%20K%20%E4%B8%AA%E9%AB%98%E9%A2%91%E5%85%83%E7%B4%A0.md) | 堆、哈希表 | 中等 | +| 0023 | [合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0023.%20%E5%90%88%E5%B9%B6K%E4%B8%AA%E5%8D%87%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、分治、堆(优先队列)、归并排序 | 困难 | +| 0239 | [滑动窗口最大值](https://leetcode.cn/problems/sliding-window-maximum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0239.%20%E6%BB%91%E5%8A%A8%E7%AA%97%E5%8F%A3%E6%9C%80%E5%A4%A7%E5%80%BC.md) | 队列,数组、滑动窗口、单调队列、堆(优先队列) | 困难 | + +## 05. 哈希表 + +### 哈希表题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0001 | [两数之和](https://leetcode.cn/problems/two-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0001.%20%E4%B8%A4%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、哈希表 | 简单 | +| 0015 | [三数之和](https://leetcode.cn/problems/3sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0015.%20%E4%B8%89%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、双指针 | 中等 | +| 0041 | [缺失的第一个正数](https://leetcode.cn/problems/first-missing-positive/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0041.%20%E7%BC%BA%E5%A4%B1%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E6%AD%A3%E6%95%B0.md) | 数组、哈希表 | 困难 | +| 0128 | [最长连续序列](https://leetcode.cn/problems/longest-consecutive-sequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0128.%20%E6%9C%80%E9%95%BF%E8%BF%9E%E7%BB%AD%E5%BA%8F%E5%88%97.md) | 并查集、数组、哈希表 | 中等 | +| 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | +| 0242 | [有效的字母异位词](https://leetcode.cn/problems/valid-anagram/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0242.%20%E6%9C%89%E6%95%88%E7%9A%84%E5%AD%97%E6%AF%8D%E5%BC%82%E4%BD%8D%E8%AF%8D.md) | 字符串、哈希表、排序 | 简单 | +| 0442 | 数组中重复的数据 | | | | +| 剑指 Offer 61 | [扑克牌中的顺子](https://leetcode.cn/problems/bu-ke-pai-zhong-de-shun-zi-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2061.%20%E6%89%91%E5%85%8B%E7%89%8C%E4%B8%AD%E7%9A%84%E9%A1%BA%E5%AD%90.md) | 数组、排序 | 简单 | +| 0268 | [丢失的数字](https://leetcode.cn/problems/missing-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0268.%20%E4%B8%A2%E5%A4%B1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组、数学 | 简单 | +| 剑指 Offer 03 | [数组中重复的数字](https://leetcode.cn/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2003.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E9%87%8D%E5%A4%8D%E7%9A%84%E6%95%B0%E5%AD%97.md) | 数组、哈希表、排序 | 简单 | + +## 06. 字符串 + +### 字符串基础题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0003 | [无重复字符的最长子串](https://leetcode.cn/problems/longest-substring-without-repeating-characters/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0003.%20%E6%97%A0%E9%87%8D%E5%A4%8D%E5%AD%97%E7%AC%A6%E7%9A%84%E6%9C%80%E9%95%BF%E5%AD%90%E4%B8%B2.md) | 字符串、哈希表、双指针、字符串、滑动窗口 | 中等 | +| 0125 | [验证回文串](https://leetcode.cn/problems/valid-palindrome/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0125.%20%E9%AA%8C%E8%AF%81%E5%9B%9E%E6%96%87%E4%B8%B2.md) | 字符串、双指针 | 简单 | +| 0005 | [最长回文子串](https://leetcode.cn/problems/longest-palindromic-substring/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0005.%20%E6%9C%80%E9%95%BF%E5%9B%9E%E6%96%87%E5%AD%90%E4%B8%B2.md) | 字符串、动态规划 | 中等 | +| 0344 | [反转字符串](https://leetcode.cn/problems/reverse-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0344.%20%E5%8F%8D%E8%BD%AC%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | 字符串 | 简单 | +| 0557 | [反转字符串中的单词 III](https://leetcode.cn/problems/reverse-words-in-a-string-iii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0557.%20%E5%8F%8D%E8%BD%AC%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E7%9A%84%E5%8D%95%E8%AF%8D%20III.md) | 字符串 | 简单 | +| 0415 | [字符串相加](https://leetcode.cn/problems/add-strings/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0415.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9B%B8%E5%8A%A0.md) | 字符串、大数加法 | 简单 | +| 0151 | [颠倒字符串中的单词](https://leetcode.cn/problems/reverse-words-in-a-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0151.%20%E9%A2%A0%E5%80%92%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E7%9A%84%E5%8D%95%E8%AF%8D.md) | 双指针、字符串 | 中等 | +| 0043 | [字符串相乘](https://leetcode.cn/problems/multiply-strings/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0043.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9B%B8%E4%B9%98.md) | 数学、字符串、模拟 | 中等 | +| 0014 | [最长公共前缀](https://leetcode.cn/problems/longest-common-prefix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0014.%20%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%89%8D%E7%BC%80.md) | 字符串 | 简单 | + +### 单模式串匹配题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0459 | [重复的子字符串](https://leetcode.cn/problems/repeated-substring-pattern/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0459.%20%E9%87%8D%E5%A4%8D%E7%9A%84%E5%AD%90%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | 字符串、字符串匹配 | 简单 | + +### 字典树题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0208 | [实现 Trie (前缀树)](https://leetcode.cn/problems/implement-trie-prefix-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0208.%20%E5%AE%9E%E7%8E%B0%20Trie%20%28%E5%89%8D%E7%BC%80%E6%A0%91%29.md) | 设计、字典树、哈希表、字符串 | 中等 | +| 0440 | 字典序的第K小数字 | | | | + +## 07. 树 + +### 二叉树的遍历题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0144 | [二叉树的前序遍历](https://leetcode.cn/problems/binary-tree-preorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0144.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树 | 中等 | +| 0094 | [二叉树的中序遍历](https://leetcode.cn/problems/binary-tree-inorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0094.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树、哈希表 | 简单 | +| 0145 | [二叉树的后序遍历](https://leetcode.cn/problems/binary-tree-postorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0145.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树 | 简单 | +| 0102 | [二叉树的层序遍历](https://leetcode.cn/problems/binary-tree-level-order-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0102.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%B1%82%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 树、广度优先搜索 | 中等 | +| 0103 | [二叉树的锯齿形层序遍历](https://leetcode.cn/problems/binary-tree-zigzag-level-order-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0103.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E9%94%AF%E9%BD%BF%E5%BD%A2%E5%B1%82%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 树、广度优先搜索、二叉树 | 中等 | +| 0236 | [二叉树的最近公共祖先](https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0236.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E8%BF%91%E5%85%AC%E5%85%B1%E7%A5%96%E5%85%88.md) | 树 | 中等 | +| 0104 | [二叉树的最大深度](https://leetcode.cn/problems/maximum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0104.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%A4%A7%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、递归 | 简单 | +| 0112 | [路径总和](https://leetcode.cn/problems/path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0112.%20%E8%B7%AF%E5%BE%84%E6%80%BB%E5%92%8C.md) | 树、深度优先搜索 | 简单 | +| 0113 | [路径总和 II](https://leetcode.cn/problems/path-sum-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0113.%20%E8%B7%AF%E5%BE%84%E6%80%BB%E5%92%8C%20II.md) | 树、深度优先搜索、回溯、二叉树 | 中等 | +| 0101 | [对称二叉树](https://leetcode.cn/problems/symmetric-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0101.%20%E5%AF%B9%E7%A7%B0%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、深度优先搜索、广度优先搜索 | 简单 | +| 0124 | [二叉树中的最大路径和](https://leetcode.cn/problems/binary-tree-maximum-path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0124.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 树、深度优先搜索、动态规划、二叉树 | 困难 | +| 0199 | [二叉树的右视图](https://leetcode.cn/problems/binary-tree-right-side-view/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0199.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%8F%B3%E8%A7%86%E5%9B%BE.md) | 树、深度优先搜索、广度优先搜索、递归、队列 | 中等 | +| 0226 | [翻转二叉树](https://leetcode.cn/problems/invert-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0226.%20%E7%BF%BB%E8%BD%AC%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、递归 | 简单 | +| 0297 | [二叉树的序列化与反序列化](https://leetcode.cn/problems/serialize-and-deserialize-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0297.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%BA%8F%E5%88%97%E5%8C%96%E4%B8%8E%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96.md) | 树、设计 | 困难 | +| 0958 | 二叉树的完全性检验 | | | | +| 0572 | 另一棵树的子树 | | | | +| 0114 | 二叉树展开为链表 | | | | +| 0100 | [相同的树](https://leetcode.cn/problems/same-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0100.%20%E7%9B%B8%E5%90%8C%E7%9A%84%E6%A0%91.md) | 树、深度优先搜索 | 简单 | +| 0111 | [二叉树的最小深度](https://leetcode.cn/problems/minimum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0111.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%B0%8F%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、广度优先搜索 | 简单 | + +### 二叉树的还原题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0105 | [从前序与中序遍历序列构造二叉树](https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0105.%20%E4%BB%8E%E5%89%8D%E5%BA%8F%E4%B8%8E%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86%E5%BA%8F%E5%88%97%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、数组、哈希表、分治、二叉树 | 中等 | +| 0106 | [从中序与后序遍历序列构造二叉树](https://leetcode.cn/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0106.%20%E4%BB%8E%E4%B8%AD%E5%BA%8F%E4%B8%8E%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86%E5%BA%8F%E5%88%97%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、数组、哈希表、分治、二叉树 | 中等 | + +### 二叉搜索树题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0098 | [验证二叉搜索树](https://leetcode.cn/problems/validate-binary-search-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0098.%20%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.md) | 树、深度优先搜索、递归 | 中等 | +| 0450 | [删除二叉搜索树中的节点](https://leetcode.cn/problems/delete-node-in-a-bst/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0450.%20%E5%88%A0%E9%99%A4%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.md) | 树 | 中等 | +| 0426 | [将二叉搜索树转化为排序的双向链表](https://leetcode.cn/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0426.%20%E5%B0%86%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E8%BD%AC%E5%8C%96%E4%B8%BA%E6%8E%92%E5%BA%8F%E7%9A%84%E5%8F%8C%E5%90%91%E9%93%BE%E8%A1%A8.md) | 栈、树、深度优先搜索、二叉搜索树、链表、二叉树、双向链表 | 中等 | +| 剑指 Offer 54 | [二叉搜索树的第k大节点](https://leetcode.cn/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2054.%20%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E7%9A%84%E7%AC%ACk%E5%A4%A7%E8%8A%82%E7%82%B9.md) | 树、深度优先搜索、二叉搜索树、二叉树 | 简单 | +| 0230 | 二叉搜索树中第K小的元素 | | | | +| 0110 | [平衡二叉树](https://leetcode.cn/problems/balanced-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0110.%20%E5%B9%B3%E8%A1%A1%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、深度优先搜索、递归 | 简单 | + +### 并查集题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0128 | [最长连续序列](https://leetcode.cn/problems/longest-consecutive-sequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0128.%20%E6%9C%80%E9%95%BF%E8%BF%9E%E7%BB%AD%E5%BA%8F%E5%88%97.md) | 并查集、数组、哈希表 | 中等 | + +## 08. 图论 + +### 图的深度优先搜索题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0200 | [岛屿数量](https://leetcode.cn/problems/number-of-islands/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0200.%20%E5%B2%9B%E5%B1%BF%E6%95%B0%E9%87%8F.md) | 搜索 | 中等 | +| 0695 | [岛屿的最大面积](https://leetcode.cn/problems/max-area-of-island/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0695.%20%E5%B2%9B%E5%B1%BF%E7%9A%84%E6%9C%80%E5%A4%A7%E9%9D%A2%E7%A7%AF.md) | 搜索 | 中等 | +| 0144 | [二叉树的前序遍历](https://leetcode.cn/problems/binary-tree-preorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0144.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树 | 中等 | +| 0094 | [二叉树的中序遍历](https://leetcode.cn/problems/binary-tree-inorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0094.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树、哈希表 | 简单 | +| 0145 | [二叉树的后序遍历](https://leetcode.cn/problems/binary-tree-postorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0145.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86.md) | 栈、树 | 简单 | +| 0129 | [求根节点到叶节点数字之和](https://leetcode.cn/problems/sum-root-to-leaf-numbers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0129.%20%E6%B1%82%E6%A0%B9%E8%8A%82%E7%82%B9%E5%88%B0%E5%8F%B6%E8%8A%82%E7%82%B9%E6%95%B0%E5%AD%97%E4%B9%8B%E5%92%8C.md) | 树、深度优先搜索、二叉树 | 中等 | +| 0124 | [二叉树中的最大路径和](https://leetcode.cn/problems/binary-tree-maximum-path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0124.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 树、深度优先搜索、动态规划、二叉树 | 困难 | +| 0199 | [二叉树的右视图](https://leetcode.cn/problems/binary-tree-right-side-view/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0199.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%8F%B3%E8%A7%86%E5%9B%BE.md) | 树、深度优先搜索、广度优先搜索、递归、队列 | 中等 | +| 0543 | [二叉树的直径](https://leetcode.cn/problems/diameter-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0543.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E7%9B%B4%E5%BE%84.md) | 二叉树 | 简单 | +| 0662 | 二叉树最大宽度 | | | | +| 0958 | 二叉树的完全性检验 | | | | +| 0572 | 另一棵树的子树 | | | | +| 0100 | [相同的树](https://leetcode.cn/problems/same-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0100.%20%E7%9B%B8%E5%90%8C%E7%9A%84%E6%A0%91.md) | 树、深度优先搜索 | 简单 | +| 0111 | [二叉树的最小深度](https://leetcode.cn/problems/minimum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0111.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%B0%8F%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、广度优先搜索 | 简单 | + +### 图的广度优先搜索题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0200 | [岛屿数量](https://leetcode.cn/problems/number-of-islands/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0200.%20%E5%B2%9B%E5%B1%BF%E6%95%B0%E9%87%8F.md) | 搜索 | 中等 | +| 0322 | [零钱兑换](https://leetcode.cn/problems/coin-change/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0322.%20%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2.md) | 动态规划 | 中等 | +| 0199 | [二叉树的右视图](https://leetcode.cn/problems/binary-tree-right-side-view/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0199.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%8F%B3%E8%A7%86%E5%9B%BE.md) | 树、深度优先搜索、广度优先搜索、递归、队列 | 中等 | +| 0662 | 二叉树最大宽度 | | | | +| 0958 | 二叉树的完全性检验 | | | | +| 0207 | [课程表](https://leetcode.cn/problems/course-schedule/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0207.%20%E8%AF%BE%E7%A8%8B%E8%A1%A8.md) | 深度优先搜索、广度优先搜索、图、拓扑排序 | 中等 | +| 0572 | 另一棵树的子树 | | | | +| 0100 | [相同的树](https://leetcode.cn/problems/same-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0100.%20%E7%9B%B8%E5%90%8C%E7%9A%84%E6%A0%91.md) | 树、深度优先搜索 | 简单 | +| 0111 | [二叉树的最小深度](https://leetcode.cn/problems/minimum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0111.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%B0%8F%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、广度优先搜索 | 简单 | +| 剑指 Offer 32 - III | [从上到下打印二叉树 III](https://leetcode.cn/problems/cong-shang-dao-xia-da-yin-er-cha-shu-iii-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2032%20-%20III.%20%E4%BB%8E%E4%B8%8A%E5%88%B0%E4%B8%8B%E6%89%93%E5%8D%B0%E4%BA%8C%E5%8F%89%E6%A0%91%20III.md) | 树、广度优先搜索、二叉树 | 中等 | + +### 图的拓扑排序题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0210 | [课程表 II](https://leetcode.cn/problems/course-schedule-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0210.%20%E8%AF%BE%E7%A8%8B%E8%A1%A8%20II.md) | 深度优先搜索、广度优先搜索、图、拓扑排序 | 中等 | + +## 09. 基础算法 + +### 枚举算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0001 | [两数之和](https://leetcode.cn/problems/two-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0001.%20%E4%B8%A4%E6%95%B0%E4%B9%8B%E5%92%8C.md) | 数组、哈希表 | 简单 | +| 0078 | [子集](https://leetcode.cn/problems/subsets/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0078.%20%E5%AD%90%E9%9B%86.md) | 位运算、数组、回溯算法 | 中等 | +| 0221 | 最大正方形 | | | | +| 0560 | [和为 K 的子数组](https://leetcode.cn/problems/subarray-sum-equals-k/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0560.%20%E5%92%8C%E4%B8%BA%20K%20%E7%9A%84%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、哈希表、前缀和 | 中等 | + +### 递归算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0024 | [两两交换链表中的节点](https://leetcode.cn/problems/swap-nodes-in-pairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0024.%20%E4%B8%A4%E4%B8%A4%E4%BA%A4%E6%8D%A2%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.md) | 递归、链表 | 中等 | +| 0206 | [反转链表](https://leetcode.cn/problems/reverse-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0206.%20%E5%8F%8D%E8%BD%AC%E9%93%BE%E8%A1%A8.md) | 链表 | 简单 | +| 0092 | 反转链表 II | | | | +| 0021 | [合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0021.%20%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%9C%89%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 递归、链表 | 简单 | +| 0509 | [斐波那契数](https://leetcode.cn/problems/fibonacci-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0509.%20%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0.md) | 数组 | 简单 | +| 0070 | [爬楼梯](https://leetcode.cn/problems/climbing-stairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0070.%20%E7%88%AC%E6%A5%BC%E6%A2%AF.md) | 动态规划 | 简单 | +| 0104 | [二叉树的最大深度](https://leetcode.cn/problems/maximum-depth-of-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0104.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%9C%80%E5%A4%A7%E6%B7%B1%E5%BA%A6.md) | 树、深度优先搜索、递归 | 简单 | +| 0124 | [二叉树中的最大路径和](https://leetcode.cn/problems/binary-tree-maximum-path-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0124.%20%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 树、深度优先搜索、动态规划、二叉树 | 困难 | +| 0226 | [翻转二叉树](https://leetcode.cn/problems/invert-binary-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0226.%20%E7%BF%BB%E8%BD%AC%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、递归 | 简单 | +| 剑指 Offer 62 | [圆圈中最后剩下的数字](https://leetcode.cn/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2062.%20%E5%9C%86%E5%9C%88%E4%B8%AD%E6%9C%80%E5%90%8E%E5%89%A9%E4%B8%8B%E7%9A%84%E6%95%B0%E5%AD%97.md) | 递归、数学 | 简单 | + +### 分治算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0053 | [最大子数组和](https://leetcode.cn/problems/maximum-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0053.%20%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84%E5%92%8C.md) | 数组、分治算法、动态规划 | 简单 | +| 0023 | [合并K个升序链表](https://leetcode.cn/problems/merge-k-sorted-lists/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0023.%20%E5%90%88%E5%B9%B6K%E4%B8%AA%E5%8D%87%E5%BA%8F%E9%93%BE%E8%A1%A8.md) | 链表、分治、堆(优先队列)、归并排序 | 困难 | +| 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | +| 0169 | [多数元素](https://leetcode.cn/problems/majority-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0169.%20%E5%A4%9A%E6%95%B0%E5%85%83%E7%B4%A0.md) | 数组、哈希表 | 简单 | +| 0014 | [最长公共前缀](https://leetcode.cn/problems/longest-common-prefix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0014.%20%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%89%8D%E7%BC%80.md) | 字符串 | 简单 | +| 剑指 Offer 33 | [二叉搜索树的后序遍历序列](https://leetcode.cn/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2033.%20%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E7%9A%84%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86%E5%BA%8F%E5%88%97.md) | 栈、树、二叉搜索树、递归、二叉树、单调栈 | 中等 | + +### 回溯算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0046 | [全排列](https://leetcode.cn/problems/permutations/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0046.%20%E5%85%A8%E6%8E%92%E5%88%97.md) | 回溯算法 | 中等 | +| 0047 | [全排列 II](https://leetcode.cn/problems/permutations-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0047.%20%E5%85%A8%E6%8E%92%E5%88%97%20II.md) | 数组、回溯 | 中等 | +| 0037 | [解数独](https://leetcode.cn/problems/sudoku-solver/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0037.%20%E8%A7%A3%E6%95%B0%E7%8B%AC.md) | 数组、回溯、矩阵 | 困难 | +| 0022 | [括号生成](https://leetcode.cn/problems/generate-parentheses/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0022.%20%E6%8B%AC%E5%8F%B7%E7%94%9F%E6%88%90.md) | 字符串、回溯算法 | 中等 | +| 0078 | [子集](https://leetcode.cn/problems/subsets/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0078.%20%E5%AD%90%E9%9B%86.md) | 位运算、数组、回溯算法 | 中等 | +| 0039 | [组合总和](https://leetcode.cn/problems/combination-sum/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0039.%20%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8C.md) | 数组、回溯 | 中等 | +| 0040 | [组合总和 II](https://leetcode.cn/problems/combination-sum-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0040.%20%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8C%20II.md) | 数组、回溯 | 中等 | +| 0093 | [复原 IP 地址](https://leetcode.cn/problems/restore-ip-addresses/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0093.%20%E5%A4%8D%E5%8E%9F%20IP%20%E5%9C%B0%E5%9D%80.md) | 字符串、回溯 | 中等 | +| 0079 | [单词搜索](https://leetcode.cn/problems/word-search/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0079.%20%E5%8D%95%E8%AF%8D%E6%90%9C%E7%B4%A2.md) | 数组、回溯算法 | 中等 | +| 0679 | 24 点游戏 | | | | + +### 贪心算法题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0053 | [最大子数组和](https://leetcode.cn/problems/maximum-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0053.%20%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84%E5%92%8C.md) | 数组、分治算法、动态规划 | 简单 | +| 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | +| 0122 | [买卖股票的最佳时机 II](https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0122.%20%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA%20II.md) | 数组、贪心算法 | 简单 | +| 0055 | [跳跃游戏](https://leetcode.cn/problems/jump-game/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0055.%20%E8%B7%B3%E8%B7%83%E6%B8%B8%E6%88%8F.md) | 贪心算法、数组、动态规划 | 中等 | +| 0402 | 移掉 K 位数字 | | | | +| 0135 | [分发糖果](https://leetcode.cn/problems/candy/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0135.%20%E5%88%86%E5%8F%91%E7%B3%96%E6%9E%9C.md) | 贪心、数组 | 困难 | +| 0134 | [加油站](https://leetcode.cn/problems/gas-station/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0134.%20%E5%8A%A0%E6%B2%B9%E7%AB%99.md) | 贪心、数组 | 中等 | +| 0670 | 最大交换 | | | | + +### 位运算题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | +| 0191 | [位1的个数](https://leetcode.cn/problems/number-of-1-bits/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0191.%20%E4%BD%8D1%E7%9A%84%E4%B8%AA%E6%95%B0.md) | 位运算 | 简单 | +| 0268 | [丢失的数字](https://leetcode.cn/problems/missing-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0268.%20%E4%B8%A2%E5%A4%B1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组、数学 | 简单 | + +## 10. 动态规划 + +### 动态规划题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0070 | [爬楼梯](https://leetcode.cn/problems/climbing-stairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0070.%20%E7%88%AC%E6%A5%BC%E6%A2%AF.md) | 动态规划 | 简单 | +| 0509 | [斐波那契数](https://leetcode.cn/problems/fibonacci-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0509.%20%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0.md) | 数组 | 简单 | +| 0121 | [买卖股票的最佳时机](https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0121.%20%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA.md) | 数组、动态规划 | 简单 | +| 0322 | [零钱兑换](https://leetcode.cn/problems/coin-change/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0322.%20%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2.md) | 动态规划 | 中等 | +| 0518 | [零钱兑换 II](https://leetcode.cn/problems/coin-change-2/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0518.%20%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2%20II.md) | 数组、动态规划 | 中等 | +| 0300 | [最长递增子序列](https://leetcode.cn/problems/longest-increasing-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0300.%20%E6%9C%80%E9%95%BF%E9%80%92%E5%A2%9E%E5%AD%90%E5%BA%8F%E5%88%97.md) | 二分查找、动态规划 | 中等 | +| 1143 | [最长公共子序列](https://leetcode.cn/problems/longest-common-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1143.%20%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%AD%90%E5%BA%8F%E5%88%97.md) | 字符串、动态规划 | 中等 | +| 0718 | [最长重复子数组](https://leetcode.cn/problems/maximum-length-of-repeated-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0718.%20%E6%9C%80%E9%95%BF%E9%87%8D%E5%A4%8D%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、二分查找、动态规划、滑动窗口、哈希函数、滚动哈希 | 中等 | +| 0064 | 最小路径和 | | | | +| 0072 | [编辑距离](https://leetcode.cn/problems/edit-distance/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0072.%20%E7%BC%96%E8%BE%91%E8%B7%9D%E7%A6%BB.md) | 字符串、动态规划 | 困难 | +| 0032 | 最长有效括号 | | | | +| 0221 | 最大正方形 | | | | +| 0062 | [不同路径](https://leetcode.cn/problems/unique-paths/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0062.%20%E4%B8%8D%E5%90%8C%E8%B7%AF%E5%BE%84.md) | 数组、动态规划 | 中等 | +| 0063 | [不同路径 II](https://leetcode.cn/problems/unique-paths-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0063.%20%E4%B8%8D%E5%90%8C%E8%B7%AF%E5%BE%84%20II.md) | 数组、动态规划、矩阵 | 中等 | +| 0152 | [乘积最大子数组](https://leetcode.cn/problems/maximum-product-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0152.%20%E4%B9%98%E7%A7%AF%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、动态规划 | 中等 | +| 0198 | [打家劫舍](https://leetcode.cn/problems/house-robber/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0198.%20%E6%89%93%E5%AE%B6%E5%8A%AB%E8%88%8D.md) | 动态规划 | 中等 | +| 0213 | [打家劫舍 II](https://leetcode.cn/problems/house-robber-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0213.%20%E6%89%93%E5%AE%B6%E5%8A%AB%E8%88%8D%20II.md) | 动态规划 | 中等 | +| 0091 | [解码方法](https://leetcode.cn/problems/decode-ways/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0091.%20%E8%A7%A3%E7%A0%81%E6%96%B9%E6%B3%95.md) | 字符串、动态规划 | 中等 | +| 0010 | 正则表达式匹配 | | | | +| 0678 | 有效的括号字符串 | | | | +| 0045 | [跳跃游戏 II](https://leetcode.cn/problems/jump-game-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0045.%20%E8%B7%B3%E8%B7%83%E6%B8%B8%E6%88%8F%20II.md) | 贪心、数组、动态规划 | 中等 | +| 0673 | [最长递增子序列的个数](https://leetcode.cn/problems/number-of-longest-increasing-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0673.%20%E6%9C%80%E9%95%BF%E9%80%92%E5%A2%9E%E5%AD%90%E5%BA%8F%E5%88%97%E7%9A%84%E4%B8%AA%E6%95%B0.md) | 动态规划 | 中等 | +| 0139 | [单词拆分](https://leetcode.cn/problems/word-break/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0139.%20%E5%8D%95%E8%AF%8D%E6%8B%86%E5%88%86.md) | 字典树、记忆化搜索、哈希表、字符串、动态规划 | 中等 | +| 0044 | 通配符匹配 | | | | +| 0120 | 三角形最小路径和 | | | | +| 0096 | [不同的二叉搜索树](https://leetcode.cn/problems/unique-binary-search-trees/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0096.%20%E4%B8%8D%E5%90%8C%E7%9A%84%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.md) | 树、二叉搜索树、数学、动态规划、二叉树 | 中等 | +| 0887 | 鸡蛋掉落 | | | | +| 0097 | 交错字符串 | | | | +| 0516 | [最长回文子序列](https://leetcode.cn/problems/longest-palindromic-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0516.%20%E6%9C%80%E9%95%BF%E5%9B%9E%E6%96%87%E5%AD%90%E5%BA%8F%E5%88%97.md) | 字符串、动态规划 | 中等 | + +### 记忆化搜索题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0329 | [矩阵中的最长递增路径](https://leetcode.cn/problems/longest-increasing-path-in-a-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0329.%20%E7%9F%A9%E9%98%B5%E4%B8%AD%E7%9A%84%E6%9C%80%E9%95%BF%E9%80%92%E5%A2%9E%E8%B7%AF%E5%BE%84.md) | 深度优先搜索、广度优先搜索、图、拓扑排序、记忆化搜索、动态规划 | 困难 | + +## 11. 补充题目 + +#### 设计数据结构题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0146 | LRU 缓存 | | | | +| 0460 | LFU 缓存 | | | | + +#### 数学题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0007 | [整数反转](https://leetcode.cn/problems/reverse-integer/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0007.%20%E6%95%B4%E6%95%B0%E5%8F%8D%E8%BD%AC.md) | 数学 | 简单 | +| 0009 | [回文数](https://leetcode.cn/problems/palindrome-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0009.%20%E5%9B%9E%E6%96%87%E6%95%B0.md) | 数学 | 简单 | +| 剑指 Offer 62 | [圆圈中最后剩下的数字](https://leetcode.cn/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2062.%20%E5%9C%86%E5%9C%88%E4%B8%AD%E6%9C%80%E5%90%8E%E5%89%A9%E4%B8%8B%E7%9A%84%E6%95%B0%E5%AD%97.md) | 递归、数学 | 简单 | +| 0168 | [Excel表列名称](https://leetcode.cn/problems/excel-sheet-column-title/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0168.%20Excel%E8%A1%A8%E5%88%97%E5%90%8D%E7%A7%B0.md) | 数学 | 简单 | +| 0400 | [第 N 位数字](https://leetcode.cn/problems/nth-digit/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0400.%20%E7%AC%AC%20N%20%E4%BD%8D%E6%95%B0%E5%AD%97.md) | 数学、二分查找 | 中等 | + +#### 模拟题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0008 | [字符串转换整数 (atoi)](https://leetcode.cn/problems/string-to-integer-atoi/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0008.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E6%8D%A2%E6%95%B4%E6%95%B0%20%28atoi%29.md) | 数学、字符串 | 中等 | +| 0165 | 比较版本号 | | | | +| 0468 | 验证IP地址 | | | | +| 0086 | 分隔链表 | | | | + +#### 前缀和 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0560 | [和为 K 的子数组](https://leetcode.cn/problems/subarray-sum-equals-k/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0560.%20%E5%92%8C%E4%B8%BA%20K%20%E7%9A%84%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、哈希表、前缀和 | 中等 | + +#### 思维锻炼题目 + +| 题号 | 标题 | 题解 | 标签 | 难度 | +| :------ | :------ | :------ | :------ | :------ | +| 0031 | 下一个排列 | | | | +| 0556 | 下一个更大元素 III | | | | +| 0470 | 用 Rand7() 实现 Rand10() | | | | + + +## 参考资料 + +- 【清单】[CodeTop 企业题库](https://codetop.cc/home) diff --git a/Contents/07.Tree/03.Segment-Tree/02.Segment-Tree-List.md b/Contents/07.Tree/03.Segment-Tree/02.Segment-Tree-List.md index 9d771f68..27f104c5 100644 --- a/Contents/07.Tree/03.Segment-Tree/02.Segment-Tree-List.md +++ b/Contents/07.Tree/03.Segment-Tree/02.Segment-Tree-List.md @@ -32,6 +32,6 @@ | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | | 0218 | [天际线问题](https://leetcode.cn/problems/the-skyline-problem/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0218.%20%E5%A4%A9%E9%99%85%E7%BA%BF%E9%97%AE%E9%A2%98.md) | 树状数组、线段树、数组、分治、有序集合、扫描线、堆(优先队列) | 困难 | -| 0391 | 完美矩形 | | | | +| 0391 | [完美矩形](https://leetcode.cn/problems/perfect-rectangle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0391.%20%E5%AE%8C%E7%BE%8E%E7%9F%A9%E5%BD%A2.md) | 数组、扫描线 | 困难 | | 0850 | 矩形面积 II | | | | diff --git a/Contents/index.md b/Contents/index.md index fe704364..8fd4d148 100644 --- a/Contents/index.md +++ b/Contents/index.md @@ -9,6 +9,8 @@ - [LeetCode 入门与攻略](./00.Introduction/03.LeetCode-Guide.md) - [LeetCode 题解(字典序排序,650+ 道题解)](./00.Introduction/04.Solutions-List.md) - [LeetCode 题解(按分类排序,推荐刷题列表 ★★★)](./00.Introduction/05.Categories-List.md) +- [LeetCode 面试最常考 100 题(按分类排序)](./00.Introduction/06.Interview-100-List.md) +- [LeetCode 面试最常考 200 题(按分类排序)](./00.Introduction/07.Interview-200-List.md) ## 01. 数组 diff --git a/README.md b/README.md index 87c92ae6..3799c0ec 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## 项目简介 -- **「算法与数据结构」** 基础知识的讲解教程,「LeetCode」650+ 道题目的详细解析。本项目易于理解,没有大跨度的思维跳跃,项目中使用部分图示、例子来帮助理解。 +- **「算法与数据结构」** 基础知识的讲解教程,「LeetCode」700+ 道题目的详细解析。本项目易于理解,没有大跨度的思维跳跃,项目中使用部分图示、例子来帮助理解。 - 本教程先从基础的数据结构和算法开始讲解,再针对不同分类的数据结构和算法,进行具体题目的讲解分析。让读者可以通过「算法基础理论学习」和「编程实战学习」相结合的方式,彻底的掌握算法知识。 @@ -26,7 +26,7 @@ 我是一名 iOS / macOS 的开发程序员,另外也是北航软院的一名非全硕士(在读)。曾在大学期间学习过算法知识,并参加过 3 年的 ACM 比赛, 但水平有限,未能取得理想成绩。但是这 3 年的 ACM 经历,给我最大的收获是锻炼了自己的逻辑思维和解决实际问题的能力,这种能力为我今后的工作、学习打下了坚实的基础。 -我从 2021 年 03 月 30 日开始每日在 LeetCode 刷题,到 2021 年 11 月 26 日已经刷了 700+ 道题目,并且完成了 650+ 道题解。努力向着 1000+、1500+、2000+ 道题前进。 +我从 2021 年 03 月 30 日开始每日在 LeetCode 刷题,到 2022 年 06 月 08 日已经刷了 1000+ 道题目,并且完成了 700+ 道题解。努力向着 1000+、1500+、2000+ 道题解前进。 在公众号 **「程序员充电站」** 里回复 "**算法打卡**",拉你进 LeetCode 算法打卡计划群一起组队打卡。 @@ -48,6 +48,8 @@ - [LeetCode 入门与攻略](./Contents/00.Introduction/03.LeetCode-Guide.md) - [LeetCode 题解(字典序排序,650+ 道题解)](./Contents/00.Introduction/04.Solutions-List.md) - [LeetCode 题解(按分类排序,推荐刷题列表 ★★★)](./Contents/00.Introduction/05.Categories-List.md) +- [LeetCode 面试最常考 100 题(按分类排序)](./Contents/00.Introduction/06.Interview-100-List.md) +- [LeetCode 面试最常考 200 题(按分类排序)](./Contents/00.Introduction/07.Interview-200-List.md) ## 01. 数组 @@ -252,4 +254,4 @@ - [动态规划优化题目](./Contents/10.Dynamic-Programming/11.DP-Optimization/04.DP-Optimization-List.md) ## 11. 附加内容 -## [12. LeetCode 题解(已完成 707 道)](./Contents/00.Introduction/04.Solutions-List.md) \ No newline at end of file +## [12. LeetCode 题解(已完成 708 道)](./Contents/00.Introduction/04.Solutions-List.md) \ No newline at end of file diff --git "a/Solutions/0391. 345円256円214円347円276円216円347円237円251円345円275円242円.md" "b/Solutions/0391. 345円256円214円347円276円216円347円237円251円345円275円242円.md" new file mode 100644 index 00000000..9f7862a2 --- /dev/null +++ "b/Solutions/0391. 345円256円214円347円276円216円347円237円251円345円275円242円.md" @@ -0,0 +1,270 @@ +## [0391. 完美矩形](https://leetcode.cn/problems/perfect-rectangle/) + +- 标签:数组、扫描线 +- 难度:困难 + +## 题目大意 + +**描述**:给定一个数组 `rectangles`,其中 `rectangles[i] = [xi, yi, ai, bi]` 表示一个坐标轴平行的矩形。这个矩形的左下顶点是 `(xi, yi)`,右上顶点是 `(ai, bi)`。 + +**要求**:如果所有矩形一起精确覆盖了某个矩形区域,则返回 `True`;否则,返回 `False`。 + +**说明**: + +- 1ドル \le rectangles.length \le 2 * 10^4$。 +- $rectangles[i].length == 4$。 +- $-10^5 \le xi, yi, ai, bi \le 10^5$。 + +**示例**: + +```Python +输入 rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]] +输出 True +解释 5 个矩形一起可以精确地覆盖一个矩形区域。 +``` + +![](https://assets.leetcode.com/uploads/2021/03/27/perectrec1-plane.jpg) + +```Python +输入 rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]] +输出 false +解释 两个矩形之间有间隔,无法覆盖成一个矩形。 +``` + +![](https://assets.leetcode.com/uploads/2021/03/27/perfectrec2-plane.jpg) + +```Python +输入 rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]] +输出 False +解释 因为中间有相交区域,虽然形成了矩形,但不是精确覆盖。 +``` + +![](https://assets.leetcode.com/uploads/2021/03/27/perfecrrec4-plane.jpg) + +## 解题思路 + +### 思路 1:线段树 + +首先我们要先判断所有小矩形的面积和是否等于外接矩形区域的面积。如果不相等,则说明出现了重叠或者空缺,明显不符合题意。 + +在两者面积相等的情况下,还可能会发生重叠的情况。接下来我们要思考如何判断重叠。 + +- 第一种思路:暴力枚举所有矩形对,两两进行比较,判断是否出现了重叠。这样的时间复杂度是 $O(n^2),ドル容易超时。 +- 第二种思路: + - 如果所有小矩形可以精确覆盖某个矩形区域,那这些小矩形一定是相互挨着的,也就是说相邻两个矩形的边会重合在一起。比如说 矩形 `A` 下边刚好是 `B` 的上边,或者是 `B` 的上边的一部分。 + - 我们可以固定一个坐标轴,比如说固定 `y` 轴,然后只看水平方向上所有矩形的边。然后我们就会发现,满足题意要求的矩形区域中,纵坐标为 `y` 的平行线上,「所有上边纵坐标为 `y` 的矩形上边区间」与「所有下边纵坐标为 `y` 的矩形下边区间」是完全一样,或者说重合在一起的(除了矩形矩形最上边和最下边只有一条,不会重合之外)。 + - 这样我们就可以用扫描线的思路,建立一个线段树。然后先固定纵坐标 `y`,将「所有上边纵坐标为 `y` 的矩形上边区间」对应的区间值减 `1`,再将「所有下边纵坐标为 `y` 的矩形下边区间」对应的区间值加 `1`。然后查询整个线代树区间值,如果区间值超过 `1`,则说明发生了重叠,不符合题目要求。如果扫描完所有的纵坐标,没有发生重叠,则说明符合题意要求。 + - 因为横坐标的范围为 $[-10^5,10^5],ドル但是最多只有 2ドル * 10^4$ 个横坐标,所以我们可以先对所有坐标做一下离散化处理,再根据离散化之后的横坐标建立线段树。 + +具体步骤如下: + +1. 通过遍历所有小矩形,计算出所有小矩形的面积和为 `area`。同时计算出矩形区域四个顶点位置,并根据四个顶点计算出矩形区域的面积为 `total_area`。如果所有小矩形面积不等于矩形区域的面积,则直接返回 `False`。 +2. 再次遍历所有小矩形,将所有坐标点进行离散化处理,将其编号存入两个哈希表 `x_dict`、`y_dict`。 +3. 使用哈希表 `top_dict`、`bottom_dict` 分别存储每个矩阵的上下两条边。将上下两条边的横坐标 `x1`、`x2`。分别存入到 `top_dict[y_dict[y2]]`、`top_dict[y_dict[y2]]` 中。 +4. 建立区间长度为横坐标个数的线段树 `STree`。 +5. 遍历所有的纵坐标,对于纵坐标 `i`: + 1. 先遍历当前纵坐标下矩阵的上边数组,即 `top_dict[i]`,取出边的横坐标 `x1`、`x2`。令区间 `[x1, x2 - 1]` 上的值减 `1`。 + 2. 再遍历当前纵坐标下矩阵的下边数组,即 `bottom_dict[i]`,取出边的横坐标 `x1`、`x2`。令区间 `[x1, x2 - 1]` 上的值加 `1`。 + 3. 如果上下边覆盖完之后,被覆盖次数超过了 `1`,则说明出现了重叠,直接返回 `Fasle`。 +6. 如果遍历完所有的纵坐标,没有发现重叠,则返回 `True`。 + +### 思路 1:线段树代码 + +```Python +# 线段树的节点类 +class SegTreeNode: + def __init__(self, val=0): + self.left = -1 # 区间左边界 + self.right = -1 # 区间右边界 + self.val = val # 节点值(区间值) + self.lazy_tag = None # 区间和问题的延迟更新标记 + + +# 线段树类 +class SegmentTree: + # 初始化线段树接口 + def __init__(self, nums, function): + self.size = len(nums) + self.tree = [SegTreeNode() for _ in range(4 * self.size)] # 维护 SegTreeNode 数组 + self.nums = nums # 原始数据 + self.function = function # function 是一个函数,左右区间的聚合方法 + if self.size> 0: + self.__build(0, 0, self.size - 1) + + # 单点更新接口:将 nums[i] 更改为 val + def update_point(self, i, val): + self.nums[i] = val + self.__update_point(i, val, 0) + + # 区间更新接口:将区间为 [q_left, q_right] 上的所有元素值加上 val + def update_interval(self, q_left, q_right, val): + self.__update_interval(q_left, q_right, val, 0) + + # 区间查询接口:查询区间为 [q_left, q_right] 的区间值 + def query_interval(self, q_left, q_right): + return self.__query_interval(q_left, q_right, 0) + + # 获取 nums 数组接口:返回 nums 数组 + def get_nums(self): + for i in range(self.size): + self.nums[i] = self.query_interval(i, i) + return self.nums + + + # 以下为内部实现方法 + + # 构建线段树实现方法:节点的存储下标为 index,节点的区间为 [left, right] + def __build(self, index, left, right): + self.tree[index].left = left + self.tree[index].right = right + if left == right: # 叶子节点,节点值为对应位置的元素值 + self.tree[index].val = self.nums[left] + return + + mid = left + (right - left) // 2 # 左右节点划分点 + left_index = index * 2 + 1 # 左子节点的存储下标 + right_index = index * 2 + 2 # 右子节点的存储下标 + self.__build(left_index, left, mid) # 递归创建左子树 + self.__build(right_index, mid + 1, right) # 递归创建右子树 + self.__pushup(index) # 向上更新节点的区间值 + + # 区间更新实现方法 + def __update_interval(self, q_left, q_right, val, index): + left = self.tree[index].left + right = self.tree[index].right + + if left>= q_left and right <= q_right: # 节点所在区间被 [q_left, q_right] 所覆盖 + if self.tree[index].lazy_tag is not None: + self.tree[index].lazy_tag += val # 将当前节点的延迟标记增加 val + else: + self.tree[index].lazy_tag = val # 将当前节点的延迟标记增加 val + self.tree[index].val += val # 当前节点所在区间每个元素值增加 val + return + + if right < q_left or left> q_right: # 节点所在区间与 [q_left, q_right] 无关 + return + + self.__pushdown(index) # 向下更新节点的区间值 + + mid = left + (right - left) // 2 # 左右节点划分点 + left_index = index * 2 + 1 # 左子节点的存储下标 + right_index = index * 2 + 2 # 右子节点的存储下标 + if q_left <= mid: # 在左子树中更新区间值 + self.__update_interval(q_left, q_right, val, left_index) + if q_right> mid: # 在右子树中更新区间值 + self.__update_interval(q_left, q_right, val, right_index) + + self.__pushup(index) # 向上更新节点的区间值 + + # 区间查询实现方法:在线段树中搜索区间为 [q_left, q_right] 的区间值 + def __query_interval(self, q_left, q_right, index): + left = self.tree[index].left + right = self.tree[index].right + + if left>= q_left and right <= q_right: # 节点所在区间被 [q_left, q_right] 所覆盖 + return self.tree[index].val # 直接返回节点值 + if right < q_left or left> q_right: # 节点所在区间与 [q_left, q_right] 无关 + return 0 + + self.__pushdown(index) + + mid = left + (right - left) // 2 # 左右节点划分点 + left_index = index * 2 + 1 # 左子节点的存储下标 + right_index = index * 2 + 2 # 右子节点的存储下标 + res_left = 0 # 左子树查询结果 + res_right = 0 # 右子树查询结果 + if q_left <= mid: # 在左子树中查询 + res_left = self.__query_interval(q_left, q_right, left_index) + if q_right> mid: # 在右子树中查询 + res_right = self.__query_interval(q_left, q_right, right_index) + + return self.function(res_left, res_right) # 返回左右子树元素值的聚合计算结果 + + # 向上更新实现方法:更新下标为 index 的节点区间值 等于 该节点左右子节点元素值的聚合计算结果 + def __pushup(self, index): + left_index = index * 2 + 1 # 左子节点的存储下标 + right_index = index * 2 + 2 # 右子节点的存储下标 + self.tree[index].val = self.function(self.tree[left_index].val, self.tree[right_index].val) + + # 向下更新实现方法:更新下标为 index 的节点所在区间的左右子节点的值和懒惰标记 + def __pushdown(self, index): + lazy_tag = self.tree[index].lazy_tag + if lazy_tag is None: + return + + left_index = index * 2 + 1 # 左子节点的存储下标 + right_index = index * 2 + 2 # 右子节点的存储下标 + + if self.tree[left_index].lazy_tag is not None: + self.tree[left_index].lazy_tag += lazy_tag # 更新左子节点懒惰标记 + else: + self.tree[left_index].lazy_tag = lazy_tag + self.tree[left_index].val += lazy_tag + + if self.tree[right_index].lazy_tag is not None: + self.tree[right_index].lazy_tag += lazy_tag # 更新右子节点懒惰标记 + else: + self.tree[right_index].lazy_tag = lazy_tag + self.tree[right_index].val += lazy_tag + self.tree[index].lazy_tag = None # 更新当前节点的懒惰标记 + + +class Solution: + def isRectangleCover(self, rectangles) -> bool: + left, right, bottom, top = math.inf, -math.inf, math.inf, -math.inf + area = 0 + x_set, y_set = set(), set() + + for rectangle in rectangles: + x1, y1, x2, y2 = rectangle + left, right = min(left, x1), max(right, x2) + bottom, top = min(bottom, y1), max(top, y2) + area += (y2 - y1) * (x2 - x1) + x_set.add(x1) + x_set.add(x2) + y_set.add(y1) + y_set.add(y2) + + total_area = (top - bottom) * (right - left) + + # 判断所有小矩形面积是否等于所有矩形顶点构成最大矩形面积,不等于则直接返回 False + if area != total_area: + return False + + # 离散化处理所有点的横坐标、纵坐标 + x_dict, y_dict = dict(), dict() + + idx = 0 + for x in sorted(list(x_set)): + x_dict[x] = idx + idx += 1 + + idy = 0 + for y in sorted(list(y_set)): + y_dict[y] = idy + idy += 1 + + # 使用哈希表 top_dict、bottom_dict 分别存储每个矩阵的上下两条边。 + bottom_dict, top_dict = collections.defaultdict(list), collections.defaultdict(list) + for i in range(len(rectangles)): + x1, y1, x2, y2 = rectangles[i] + bottom_dict[y_dict[y1]].append([x_dict[x1], x_dict[x2]]) + top_dict[y_dict[y2]].append([x_dict[x1], x_dict[x2]]) + + # 建立线段树 + self.STree = SegmentTree([0 for _ in range(len(x_set))], lambda x, y: max(x, y)) + + for i in range(idy): + for x1, x2 in top_dict[i]: + self.STree.update_interval(x1, x2 - 1, -1) + for x1, x2 in bottom_dict[i]: + self.STree.update_interval(x1, x2 - 1, 1) + cnt = self.STree.query_interval(0, len(x_set) - 1) + if cnt> 1: + return False + return True +``` + +## 参考资料 + +- 【题解】[线段树+扫描线 - 完美矩形 - 力扣](https://leetcode.cn/problems/perfect-rectangle/solution/xian-duan-shu-sao-miao-xian-by-lucifer10-raw5/) \ No newline at end of file diff --git "a/Solutions/345円211円221円346円214円207円 Offer 45. 346円212円212円346円225円260円347円273円204円346円216円222円346円210円220円346円234円200円345円260円217円347円232円204円346円225円260円.md" "b/Solutions/345円211円221円346円214円207円 Offer 45. 346円212円212円346円225円260円347円273円204円346円216円222円346円210円220円346円234円200円345円260円217円347円232円204円346円225円260円.md" index bb5cdb9c..cfd31684 100644 --- "a/Solutions/345円211円221円346円214円207円 Offer 45. 346円212円212円346円225円260円347円273円204円346円216円222円346円210円220円346円234円200円345円260円217円347円232円204円346円225円260円.md" +++ "b/Solutions/345円211円221円346円214円207円 Offer 45. 346円212円212円346円225円260円347円273円204円346円216円222円346円210円220円346円234円200円345円260円217円347円232円204円346円225円260円.md" @@ -5,17 +5,35 @@ ## 题目大意 -给定一个非负整数数组 `nums`。 +**描述**:给定一个非负整数数组 `nums`。 -要求:将数组中的数字拼接起来排成一个数,打印能拼接出的所有数字中的最小的一个。 +**要求**:将数组中的数字拼接起来排成一个数,打印能拼接出的所有数字中的最小的一个。 + +**说明**: + +- 0ドル < nums.length \le 100$。 +- 输出结果可能非常大,所以你需要返回一个字符串而不是整数。 +- 拼接起来的数字可能会有前导 `0`,最后结果不需要去掉前导 `0`。 + +**示例**: + +```Python +输入 [3,30,34,5,9] +输出 "3033459" +``` ## 解题思路 -本质上是给数组进行排序。假设 `x`、`y` 是数组 `nums` 中的两个元素。如果拼接字符串 `x + y> y + x`,则 `x < y `。`x` 应该排在 `y` 前面。反之,则 `x> y`。 +### 思路 1:自定义排序 + +本质上是给数组进行排序。假设 `x`、`y` 是数组 `nums` 中的两个元素。则排序的判断规则如下所示: + +- 如果拼接字符串 `x + y> y + x`,则 `x` 大于 `y `,`y` 应该排在 `x` 前面,从而使拼接起来的数字尽可能的小。 +- 反之,如果拼接字符串 `x + y < y + x`,则 `x` 小于 `y `,`x` 应该排在 `y` 前面,从而使拼接起来的数字尽可能的小。 按照上述规则,对原数组进行排序。这里使用了 `functools.cmp_to_key` 自定义排序函数。 -## 代码 +### 思路 1:自定义排序代码 ```Python import functools @@ -35,3 +53,6 @@ class Solution: return ''.join(nums_s) ``` +## 参考资料 + +- 【题解】[剑指 Offer 45. 把数组排成最小的数(自定义排序,清晰图解) - 把数组排成最小的数 - 力扣](https://leetcode.cn/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/solution/mian-shi-ti-45-ba-shu-zu-pai-cheng-zui-xiao-de-s-4/)

AltStyle によって変換されたページ (->オリジナル) /