diff --git a/README.md b/README.md index b349894..5b22d23 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Leetcode-retag + 重新分类 Leetcode 高频题 - 题目按照 Leetcode 题目频率降序排列 @@ -7,6 +8,10 @@ ## 𐁙 链表 + + +
Leetcode-cn
+ ### 单链表: ##### 简单: @@ -38,8 +43,8 @@ - [430. 扁平化多级双向链表](https://leetcode-cn.com/problems/flatten-a-multilevel-doubly-linked-list/) - [725. 分隔链表](https://leetcode-cn.com/problems/split-linked-list-in-parts/) - ##### 困难 + - [25. K 个一组翻转链表](https://leetcode-cn.com/problems/reverse-nodes-in-k-group/) ### 双链表: @@ -57,24 +62,26 @@ ##### 困难 -- [23. 合并K个升序链表](https://leetcode-cn.com/problems/merge-k-sorted-lists/) - +- [23. 合并 K 个升序链表](https://leetcode-cn.com/problems/merge-k-sorted-lists/) ## 𐀴 树 ### 二叉搜索树 ##### 简单 + - [108. 将有序数组转换为二叉搜索树](https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/) ##### 中等 + - [98. 验证二叉搜索树](https://leetcode-cn.com/problems/validate-binary-search-tree/) - [96. 不同的二叉搜索树](https://leetcode-cn.com/problems/unique-binary-search-trees/) - [95. 不同的二叉搜索树 II](https://leetcode-cn.com/problems/unique-binary-search-trees-ii/) - [173. 二叉搜索树迭代器](https://leetcode-cn.com/problems/binary-search-tree-iterator/) -- [230. 二叉搜索树中第K小的元素](https://leetcode-cn.com/problems/kth-smallest-element-in-a-bst/) +- [230. 二叉搜索树中第 K 小的元素](https://leetcode-cn.com/problems/kth-smallest-element-in-a-bst/) ##### 困难 + - [99. 恢复二叉搜索树](https://leetcode-cn.com/problems/recover-binary-search-tree/) ### 遍历 @@ -93,10 +100,10 @@ - [106. 从中序与后序遍历序列构造二叉树](https://leetcode-cn.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) - [144. 二叉树的前序遍历](https://leetcode-cn.com/problems/binary-tree-preorder-traversal/) - ### 路径 | 深度 | 翻转 ##### 简单 + - [104. 二叉树的最大深度](https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/) - [101. 对称二叉树](https://leetcode-cn.com/problems/symmetric-tree/) - [226. 翻转二叉树](https://leetcode-cn.com/problems/invert-binary-tree/) @@ -109,6 +116,7 @@ - [111. 二叉树的最小深度](https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/) ##### 中等 + - [236. 二叉树的最近公共祖先](https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/) - [222. 完全二叉树的节点个数](https://leetcode-cn.com/problems/count-complete-tree-nodes/) - [113. 路径总和 II](https://leetcode-cn.com/problems/path-sum-ii/) @@ -119,15 +127,16 @@ - [199. 二叉树的右视图](https://leetcode-cn.com/problems/binary-tree-right-side-view/) ##### 困难 + - [124. 二叉树中的最大路径和](https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/) - [297. 二叉树的序列化与反序列化](https://leetcode-cn.com/problems/serialize-and-deserialize-binary-tree/) - ## 𐃭 栈 ### 基础 ##### 简单 + - [20. 有效的括号](https://leetcode-cn.com/problems/valid-parentheses/) - [1047. 删除字符串中的所有相邻重复项](https://leetcode-cn.com/problems/remove-all-adjacent-duplicates-in-string/) - [232. 用栈实现队列](https://leetcode-cn.com/problems/implement-queue-using-stacks/) @@ -138,6 +147,7 @@ - [844. 比较含退格的字符串](https://leetcode-cn.com/problems/backspace-string-compare/) ##### 中等 + - [1190. 反转每对括号间的子串](https://leetcode-cn.com/problems/reverse-substrings-between-each-pair-of-parentheses/) - [394. 字符串解码](https://leetcode-cn.com/problems/decode-string/) - [456. 132 模式](https://leetcode-cn.com/problems/132-pattern/) @@ -153,40 +163,44 @@ - [341. 扁平化嵌套列表迭代器](https://leetcode-cn.com/problems/flatten-nested-list-iterator/) ##### 困难 + - [224. 基本计算器](https://leetcode-cn.com/problems/basic-calculator/) - [726. 原子的数量](https://leetcode-cn.com/problems/number-of-atoms/) - ### 单调栈 ##### 简单 + - [496. 下一个更大元素 I](https://leetcode-cn.com/problems/next-greater-element-i/) ##### 中等 + - [739. 每日温度](https://leetcode-cn.com/problems/daily-temperatures/) -- [402. 移掉K位数字](https://leetcode-cn.com/problems/remove-k-digits/) +- [402. 移掉 K 位数字](https://leetcode-cn.com/problems/remove-k-digits/) - [316. 去除重复字母](https://leetcode-cn.com/problems/remove-duplicate-letters/) - [1124. 表现良好的最长时间段](https://leetcode-cn.com/problems/longest-well-performing-interval/) ##### 困难 + - [42. 接雨水](https://leetcode-cn.com/problems/trapping-rain-water/) - [84. 柱状图中最大的矩形](https://leetcode-cn.com/problems/largest-rectangle-in-histogram/) - [85. 最大矩形](https://leetcode-cn.com/problems/maximal-rectangle/) - [321. 拼接最大数](https://leetcode-cn.com/problems/create-maximum-number/) - ## 𐂧 堆 ### 基础 ##### 简单 + - [1046. 最后一块石头的重量](https://leetcode-cn.com/problems/last-stone-weight/) - [703. 数据流中的第 K 大元素](https://leetcode-cn.com/problems/kth-largest-element-in-a-stream/) ##### 中等 -- [215. 数组中的第K个最大元素](https://leetcode-cn.com/problems/kth-largest-element-in-an-array/) + +- [215. 数组中的第 K 个最大元素](https://leetcode-cn.com/problems/kth-largest-element-in-an-array/) - [347. 前 K 个高频元素](https://leetcode-cn.com/problems/top-k-frequent-elements/) -- [692. 前K个高频单词](https://leetcode-cn.com/problems/top-k-frequent-words/) +- [692. 前 K 个高频单词](https://leetcode-cn.com/problems/top-k-frequent-words/) - [378. 有序矩阵中第 K 小的元素](https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix/) - [451. 根据字符出现频率排序](https://leetcode-cn.com/problems/sort-characters-by-frequency/) - [743. 网络延迟时间](https://leetcode-cn.com/problems/network-delay-time/) @@ -194,6 +208,7 @@ - [973. 最接近原点的 K 个点](https://leetcode-cn.com/problems/k-closest-points-to-origin/) ##### 困难 + - [239. 滑动窗口最大值](https://leetcode-cn.com/problems/sliding-window-maximum/) - [295. 数据流的中位数](https://leetcode-cn.com/problems/find-median-from-data-stream/) - [218. 天际线问题](https://leetcode-cn.com/problems/the-skyline-problem/) @@ -201,23 +216,25 @@ ### 贪心 ##### 中等 + - [264. 丑数 II](https://leetcode-cn.com/problems/ugly-number-ii/) - [767. 重构字符串](https://leetcode-cn.com/problems/reorganize-string/) -- [373. 查找和最小的K对数字](https://leetcode-cn.com/problems/find-k-pairs-with-smallest-sums/) +- [373. 查找和最小的 K 对数字](https://leetcode-cn.com/problems/find-k-pairs-with-smallest-sums/) - [313. 超级丑数](https://leetcode-cn.com/problems/super-ugly-number/) - ## 𐀋 动态规划 ### 一维 ##### 简单 + - [70. 爬楼梯](https://leetcode-cn.com/problems/climbing-stairs/) - [53. 最大子序和](https://leetcode-cn.com/problems/maximum-subarray/) - [121. 买卖股票的最佳时机](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/) - [746. 使用最小花费爬楼梯](https://leetcode-cn.com/problems/min-cost-climbing-stairs/) ##### 中等 + - [337. 打家劫舍 III](https://leetcode-cn.com/problems/house-robber-iii/) - [322. 零钱兑换](https://leetcode-cn.com/problems/coin-change/) - [300. 最长递增子序列](https://leetcode-cn.com/problems/longest-increasing-subsequence/) @@ -229,6 +246,7 @@ - [279. 完全平方数](https://leetcode-cn.com/problems/perfect-squares/) ##### 困难 + - [32. 最长有效括号](https://leetcode-cn.com/problems/longest-valid-parentheses/) - [354. 俄罗斯套娃信封问题](https://leetcode-cn.com/problems/russian-doll-envelopes/) - [123. 买卖股票的最佳时机 III](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/) @@ -236,6 +254,7 @@ ### 二维 ##### 中等 + - [5. 最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring/) - [1143. 最长公共子序列](https://leetcode-cn.com/problems/longest-common-subsequence/) - [131. 分割回文串](https://leetcode-cn.com/problems/palindrome-partitioning/) @@ -247,6 +266,7 @@ - [494. 目标和](https://leetcode-cn.com/problems/target-sum/) ##### 困难 + - [10. 正则表达式匹配](https://leetcode-cn.com/problems/regular-expression-matching/) - [72. 编辑距离](https://leetcode-cn.com/problems/edit-distance/) - [887. 鸡蛋掉落](https://leetcode-cn.com/problems/super-egg-drop/) @@ -257,4 +277,240 @@ ## 贪心 #### 中等 + - [946. 验证栈序列](https://leetcode-cn.com/problems/validate-stack-sequences/) + +
+ + + +
Leetcode
+ +##### Simple: + +- [206. Invert linked list](https://leetcode.com/problems/reverse-linked-list/) +- [141. Ring linked list](https://leetcode.com/problems/linked-list-cycle/) +- [83. Delete duplicate elements in the sorted list](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) +- [234. Palindrome list](https://leetcode.com/problems/palindrome-linked-list/) +- [203. Remove linked list elements](https://leetcode.com/problems/remove-linked-list-elements/) +- [237. Delete nodes in the linked list](https://leetcode.com/problems/delete-node-in-a-linked-list/) +- [876. The middle node of the linked list](https://leetcode.com/problems/middle-of-the-linked-list/) + +##### Medium + +- [92. Invert linked List II] (https://leetcode.com/problems/reverse-linked-list-ii/) +- [143. Rearrange linked lists](https://leetcode.com/problems/reorder-list/) +- [82. Delete duplicate elements in the sorted list II] (https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) +- [19. Delete the penultimate N-th node of the linked list](https://leetcode.com/problems/remove-nth-node-from-end-of-list/) +- [148. Sort linked list](https://leetcode.com/problems/sort-list/) +- [86. Separate linked list](https://leetcode.com/problems/partition-list/) +- [61. Rotate the linked list](https://leetcode.com/problems/rotate-list/) +- [142. Ring Linked List II] (https://leetcode.com/problems/linked-list-cycle-ii/) +- [147. Insert and sort the linked list](https://leetcode.com/problems/insertion-sort-list/) +- [138. Copy a linked list with random pointers](https://leetcode.com/problems/copy-list-with-random-pointer/) +- [24. Two pairs of nodes in the swap list](https://leetcode.com/problems/swap-nodes-in-pairs/) +- [328. Parity linked list](https://leetcode.com/problems/odd-even-linked-list/) +- [707. Design linked list](https://leetcode.com/problems/design-linked-list/) +- [109. Ordered linked list conversion Binary search tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) +- [430. Flattened multi-level doubly linked list](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/) +- [725. Separate linked list](https://leetcode.com/problems/split-linked-list-in-parts/) + +##### Difficulty + +- [25. K a set of flip linked lists](https://leetcode.com/problems/reverse-nodes-in-k-group/) + +### Double-linked list: + +##### Simple: + +- [21. Merge two ordered linked lists](https://leetcode.com/problems/merge-two-sorted-lists/) +- [160. Intersecting linked lists](https://leetcode.com/problems/intersection-of-two-linked-lists/) + +##### Intermediate + +- [2. Two numbers add up](https://leetcode.com/problems/add-two-numbers/) +- [445. Add two numbers II] (https://leetcode.com/problems/add-two-numbers-ii/) +- [1669. Merge two linked lists](https://leetcode.com/problems/merge-in-between-linked-lists/) + +##### Difficulty + +- [23. Merge K ascending linked lists](https://leetcode.com/problems/merge-k-sorted-lists/) + +## Orangutan Tree + +### Binary Search tree + +##### Simple + +- [108. Convert an ordered array to a binary search tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) + +##### Medium + +- [98. Verify binary search tree](https://leetcode.com/problems/validate-binary-search-tree/) +- [96. Different binary search trees](https://leetcode.com/problems/unique-binary-search-trees/) +- [95. Different binary search trees II] (https://leetcode.com/problems/unique-binary-search-trees-ii/) +- [173. Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator/) +- [230. The K-th small element in the binary search tree](https://leetcode.com/problems/kth-smallest-element-in-a-bst/) + +##### Difficulty + +- [99. Restore Binary search tree](https://leetcode.com/problems/recover-binary-search-tree/) + +### Traversal + +##### Simple + +- [145. After-order traversal of binary trees](https://leetcode.com/problems/binary-tree-postorder-traversal/) +- [94. Middle order traversal of binary trees](https://leetcode.com/problems/binary-tree-inorder-traversal/) + +##### Medium + +- [105. Construct binary trees from pre-and middle-order traversal sequences](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) +- [102. Hierarchical traversal of binary trees](https://leetcode.com/problems/binary-tree-level-order-traversal/) +- [103. Zigzag hierarchical traversal of binary trees](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) +- [107. Hierarchical Traversal of binary trees II] (https://leetcode.com/problems/binary-tree-level-order-traversal-ii/) +- [106. Construct binary trees from sequential and post-sequential traversal sequences](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) +- [144. Preorder traversal of binary trees](https://leetcode.com/problems/binary-tree-preorder-traversal/) + +### Path / Depth / Flip + +##### Simple + +- [104. Maximum depth of a binary tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/) +- [101. Symmetric binary tree](https://leetcode.com/problems/symmetric-tree/) +- [226. Flip binary tree](https://leetcode.com/problems/invert-binary-tree/) +- [543. The diameter of the binary tree](https://leetcode.com/problems/diameter-of-binary-tree/) +- [257. All paths to a binary tree](https://leetcode.com/problems/binary-tree-paths/) +- [110. Balanced binary tree](https://leetcode.com/problems/balanced-binary-tree/) +- [617. Merge binary trees](https://leetcode.com/problems/merge-two-binary-trees/) +- [100. The same tree](https://leetcode.com/problems/same-tree/) +- [112. Path sum](https://leetcode.com/problems/path-sum/) +- [111. Minimum depth of a binary tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/) + +##### Medium + +- [236. The nearest common ancestor of binary trees](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/) +- [222. The number of nodes of a complete binary tree](https://leetcode.com/problems/count-complete-tree-nodes/) +- [113. Path Sum II] (https://leetcode.com/problems/path-sum-ii/) +- [437. Path sum III] (https://leetcode.com/problems/path-sum-iii/) +- [129. Find the sum of the root node to leaf node numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers/) +- [662. Maximum width of binary tree](https://leetcode.com/problems/maximum-width-of-binary-tree/) +- [114. Binary tree expands to linked list](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/) +- [199. Right view of a binary tree](https://leetcode.com/problems/binary-tree-right-side-view/) + +##### Difficulty + +- [124. The maximum path in a binary tree and](https://leetcode.com/problems/binary-tree-maximum-path-sum/) +- [297. Serialization and Deserialization of binary trees](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/) + +## 𐃭 Stack + +### Basic + +##### Simple + +- [20. Valid parentheses](https://leetcode.com/problems/valid-parentheses/) +- [1047. Remove all adjacent duplicates in the string](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/) +- [232. Implement queues with stacks](https://leetcode.com/problems/implement-queue-using-stacks/) +- [155. Minimum stack](https://leetcode.com/problems/min-stack/) +- [225. Implement stacks with queues](https://leetcode.com/problems/implement-stack-using-queues/) +- [1021. Remove the outermost parentheses](https://leetcode.com/problems/remove-outermost-parentheses/) +- [682. Baseball Games](https://leetcode.com/problems/baseball-game/) +- [844. Compare strings with backspace](https://leetcode.com/problems/backspace-string-compare/) + +##### Medium + +- [1190. Invert the substring between each pair of parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/) +- [394. String decoding](https://leetcode.com/problems/decode-string/) +- [456. 132 mode](https://leetcode.com/problems/132-pattern/) +- [227. Basic Calculator II] (https://leetcode.com/problems/basic-calculator-ii/) +- [150. Inverse Polish expression evaluation](https://leetcode.com/problems/evaluate-reverse-polish-notation/) +- [503. Next Larger Element II](https://leetcode.com/problems/next-greater-element-ii/) +- [71. Simplified path](https://leetcode.com/problems/simplify-path/) +- [856. Scores in parentheses are listed in this order from left to right. https://leetcode.com/problems/score-of-parentheses/) +- [907. The sum of the minimum values of the subarray](https://leetcode.com/problems/sum-of-subarray-minimums/) +- [385. Mini Parser](https://leetcode.com/problems/mini-parser/) +- [1249. Remove invalid parentheses](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/) +- [636. Exclusive time of the function](https://leetcode.com/problems/exclusive-time-of-functions/) +- [341. Flattening nested list iterators](https://leetcode.com/problems/flatten-nested-list-iterator/) + +##### Difficulty + +- [224. Basic Calculator](https://leetcode.com/problems/basic-calculator/) +- [726. Number of atoms](https://leetcode.com/problems/number-of-atoms/) + +### Monotonic stack + +##### Simple + +- [496. Next larger element I](https://leetcode.com/problems/next-greater-element-i/) + +##### Medium + +- [739. Daily temperature](https://leetcode.com/problems/daily-temperatures/) +- [402. Remove the K-digit] (https://leetcode.com/problems/remove-k-digits/) +- [316. Remove duplicate letters](https://leetcode.com/problems/remove-duplicate-letters/) +- [1124. The longest period of good performance](https://leetcode.com/problems/longest-well-performing-interval/) + +##### Difficulty + +- [42. It is found in the Democratic Republic of the Congo. https://leetcode.com/problems/trapping-rain-water/) +- [84. The largest rectangle in the histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/) +- [85. Maximum rectangle](https://leetcode.com/problems/maximal-rectangle/) +- [321. Maximum number of splices](https://leetcode.com/problems/create-maximum-number/) + +## 𐂧 Heap + +### Basic + +##### Simple + +- [1046. The weight of the last stone](https://leetcode.com/problems/last-stone-weight/) +- [703. The K-th largest element in the data stream](https://leetcode.com/problems/kth-largest-element-in-a-stream/) + +##### Medium + +- [215. The K-th largest element in the array](https://leetcode.com/problems/kth-largest-element-in-an-array/) +- [347. Former K high frequency elements](https://leetcode.com/problems/top-k-frequent-elements/) +- [692. The first K high frequency words](https://leetcode.com/problems/top-k-frequent-words/) +- [378. K-th small element in an ordered matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/) +- [451. Sort by frequency of character occurrence](https://leetcode.com/problems/sort-characters-by-frequency/) +- [743. Network delay time](https://leetcode.com/problems/network-delay-time/) +- [787. The cheapest flight within Stop K] (https://leetcode.com/problems/cheapest-flights-within-k-stops/) +- [973. The K points closest to the origin](https://leetcode.com/problems/k-closest-points-to-origin/) + +##### Difficulty + +- [239. Sliding window maximum] (https://leetcode.com/problems/sliding-window-maximum/) +- [295. The median of the data stream](https://leetcode.com/problems/find-median-from-data-stream/) +- [218. The Skyline problem](https://leetcode.com/problems/the-skyline-problem/) + +### Greed + +##### Medium + +- [264. Ugly Number II](https://leetcode.com/problems/ugly-number-ii/) +- [767. Refactor the string](https://leetcode.com/problems/reorganize-string/) +- [373. Find and minimum K pairs of numbers](https://leetcode.com/problems/find-k-pairs-with-smallest-sums/) +- [313. Super ugly number](https://leetcode.com/problems/super-ugly-number/) + +## 𐀋 Dynamic Planning + +### One-dimensional + +##### Simple + +- [70. Climbing stairs](https://leetcode.com/problems/climbing-stairs/) +- [53. Maximum suborder and](https://leetcode.com/problems/maximum-subarray/) +- [121. The best time to buy and sell stocks](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) +- [746. Use the minimum cost to climb stairs](https://leetcode.com/problems/min-cost-climbing-stairs/) + +##### Medium + +- [337. Home Robbery III](https://leetcode.com/problems/house-robber-iii/) +- [322. Change exchange](https://leetcode.com/problems/coin-change/) +- [300. Longest incremental subsequence](https://leetcode.com/problems/longest-increasing-subsequence/) +- [139. Word splitting](https://leetcode.com/problems/word-break/) +- [152. Maximum sub-array of product](https://leetcode.com/problems/maximum-product-subarray/) + +