LeetCode collection.
Date | Question Numbers | ✨ Star ! |
---|---|---|
数组和动态数组 | ||
73. Set Matrix Zeroes | ||
48. Rotate Image | ||
344. Reverse String | ||
414. Third Maximum Number | ||
448. Find All Numbers Disappeared in an Array | ||
66. Plus One | ||
238. Product of Array Except Self | ||
697. Degree of an Array | ||
849. Maximize Distance to Closest Person | ||
189. Rotate Array | ||
Lint-39. Recover Rotated Sorted Array 三步翻转法 !!!! | ||
54. Spiral Matrix | ||
递归 | ||
784. Letter Case Permutation | ||
31. Next Permutation | ||
二分搜索 | ||
50. Pow(x, n) | ||
34. Find First and Last Position of Element in Sorted Array | 1-yes | |
35. Search Insert Position | 1-yes | |
658. Find K Closest Elements | 1-no | |
33. Search in Rotated Sorted Array | 1-no | |
81. Search in Rotated Sorted Array II | 1-no | |
153. Find Minimum in Rotated Sorted Array | ||
154. Find Minimum in Rotated Sorted Array II | ||
702. Search in a Sorted Array of Unknown Size 这个题定量分析 ! | 1-no | |
74. Search a 2D Matrix | 1-no | |
240. Search a 2D Matrix II | 1-no | |
162. Find Peak Element | 1-no | |
69. Sqrt(x) | 1-yes | |
Lint-586. Sqrt(x) II | ||
4. Median of Two Sorted Array 和下面的题是一样的 | ||
Lint-931. Median of K Sorted Arrays | ||
Laicode: Kth Smallest In Two Sorted Arrays 这个题非常重要!可以到 logn+logk | bilibili | |
7. Reverse Integer | ||
475. Heaters | ||
57. Insert Interval | ||
349. Intersection of Two Arrays | ||
Lint-140. Fast Power | ||
378. Kth Smallest Element in a Sorted Matrix 二分中的逼近法 | ||
302. Smallest Rectangle Enclosing Black Pixels 二分中的逼近法 | ||
Lint-183. Wood Cut | ||
经验:并不是所有二分法都适用于 left+1<right, 对于可以排除mid的问题,使用left<=right更简便 | ||
线段树 segment tree | ||
Lint-201. Segment Tree Build | ||
Lint-439. Segment Tree Build II | max的,触底反弹 | |
Lint-202. Segment Tree Query | ||
Lint-247. Segment Tree Query II | ||
Lint-203. Segment Tree Modify | ||
206. Interval Sum | ||
207. Interval Sum II | ||
248. Count of Smaller Number | ||
249. Count of Smaller Number before itself | ||
307. Range Sum Query - Mutable 还没做 | ||
817. Range Sum Query 2D - Mutable | ||
665. Range Sum Query 2D - Immutable | ||
扫描线 | ||
Lint-391. Number of Airplanes in the Sky | ||
218. The Skyline Problem | ||
253. Meeting Rooms II | ||
排序 | ||
969. Pancake Sorting | ||
347. Top K Frequent Elements 桶排序 | ||
296. Best Meeting Point | ||
Lint-139. Subarray Sum Closest | ||
643. Maximum Average Subarray I | ||
644. Maximum Average Subarray II 二分法,尺举法 | ||
Lint-64. Merge Sorted Array | ||
56. Merge Intervals | 关键是保证开头是sort | |
Lint-577. Merge K Sorted Interval Lists | ||
280. Wiggle Sort | ||
324. Wiggle Sort II 不会 | ||
164. Maximum Gap | ||
归并变种 | ||
493. Reverse Pairs 归并排序 | ||
--- | ||
快排变种 | ||
215. Kth Largest Element in an Array | ||
Lint-143. Sort Colors II 彩虹排序 | ||
分治法 | ||
349. Intersection of Two Arrays | ||
350. Intersection of Two Arrays II | ||
53.Maximum Subarray 这题实际是动态规划 | ||
311. Sparse Matrix Multiplication | ||
523. Continuous Subarray Sum | ||
241. Different Ways to Add Parentheses 分治,递归 | ||
链表 | ||
237. Delete Node in a Linked List | ||
876. Middle of the Linked List | ||
141. Linked List Cycle | ||
142. Linked List Cycle II (找到环的开始) | ||
19. Remove Nth Node From End of List | ||
21. Merge Two Sorted Lists | ||
160. Intersection of Two Linked Lists | ||
147. Insertion Sort List | ||
148. Sort List | ||
86. Partition List | ||
206. Reverse Linked List | ||
92. Reverse Linked List II | ||
25. Reverse Nodes in k-Group | 没做出来,要重新看一遍 | |
234. Palindrome Linked List 回文 | 不会 | |
83. Remove Duplicates from Sorted List | ||
82. Remove Duplicates from Sorted List II | ||
61. Rotate List 还没做 | ||
24. Swap Nodes in Pairs | ||
堆栈和队列 | ||
32. Longest Valid Parentheses | ||
71. Simplify Path | ||
394. Decode String | ||
682. Baseball Game | ||
735. Asteroid Collision | ||
239. Sliding Window Maximum 还没做,优先考虑用队列的方法 | ||
224. Basic Calculator | ||
456. 132 Pattern | ||
402. Remove K Digits | ||
946. Validate Stack Sequences | ||
621. Task Scheduler 还没做 | ||
622. Design Circular Queue 还没做 | ||
973. K Closest Points to Origin | ||
栈 Stack | 栈的精髓:把 递归中最后处理 的 压在最前面 | |
232. Implement Queue using Stacks | ||
225. Implement Stack using Queues | ||
20. Valid Parentheses | ||
150. Evaluate Reverse Polish Notation 反波兰表达式 | ||
155. Min Stack | ||
Lint-22. Flatten List | ||
341. Flatten Nested List Iterator | ||
251. Flatten 2D Vector | ||
单调栈 | ||
739. Daily Temperatures | ||
1019. Next Greater Node In Linked List | ||
496. Next Greater Element I 单调栈 | ||
503. Next Greater Element II | ||
84. Largest Rectangle in Histogram | ||
85. Maximal Rectangle | ||
654. Maximum Binary Tree 单调栈 经典~!! | ||
Lint-367. Expression Tree Build 和leetcode654一样 | ||
Lint-368. Expression Evaluation 中缀变后缀表达式再计算 | ||
---- | ||
队列 queue | ||
Lint-230. Animal Shelter 双端队列,链表 | ||
346. Moving Average from Data Stream | ||
239. Sliding Window Maximum | ||
哈希表 | ||
387. First Unique Character in a String 这题要用过一遍的方法!非常重要! | ||
146. LRU Cache | ||
Lint-685. First Unique Number in Data Stream | ||
349. Intersection of Two Arrays | ||
350. Intersection of Two Arrays II | ||
771. Jewels and Stones | ||
217. Contains Duplicate | ||
219. Contains Duplicate II | ||
811. Subdomain Visit Count | ||
500. Keyboard Row | ||
380. Insert Delete GetRandom O(1) | ||
36. Valid Sudoku | ||
Lint-594. strStr II 这题不用会 | https://www.jiuzhang.com/video/rabin-karp | |
Lint-138. Subarray Sum | ||
Lint-404. Subarray Sum II | ||
Lint-405. Submatrix Sum | ||
Lint-944. Maximum Submatrix | 和53一样,降维攻击 | |
560. Subarray Sum Equals K | ||
53. Maximum Subarray 前缀和 | ||
Lint-558. Sliding Window Matrix Maximum | ||
堆 | ||
215. Kth Largest Element in an Array | y | |
692. Top K Frequent Words | ||
263. Ugly Number | ||
264. Ugly Number II | ||
373. Find K Pairs with Smallest Sums | n | |
23. Merge k Sorted Lists | ||
295. Find Median from Data Stream | ||
480. Sliding Window Median | ||
502. IPO | ||
451. Sort Characters By Frequency 还没做 | ||
871. Minimum Number of Refueling Stops 还没做 | ||
407. Trapping Rain Water II | ||
378. Kth Smallest Element in a Sorted Matrix | klogk | |
42. Trapping Rain Water 单调栈 | ||
407. Trapping Rain Water II | ||
树 | ||
二叉树 | ||
270. Closest Binary Search Tree Value | ||
272. Closest Binary Search Tree Value II | ||
114. Flatten Binary Tree to Linked List | ||
110. Balanced Binary Tree | ||
98. Validate Binary Search Tree 判断二叉搜索树 | ||
173. Binary Search Tree Iterator | ||
235. Lowest Common Ancestor of a Binary Search Tree | ||
236. Lowest Common Ancestor of a Binary Tree | ||
108. Convert Sorted Array to Binary Search Tree | ||
109. Convert Sorted List to Binary Search Tree | ||
298. Binary Tree Longest Consecutive Sequence | ||
549. Binary Tree Longest Consecutive Sequence II | ||
958. Check Completeness of a Binary Tree | ||
---- | ||
104. Maximum Depth of Binary Tree | ||
110. Balanced Binary Tree | ||
101. Symmetric Tree | ||
100. Same Tree | ||
700. Search in a Binary Search Tree | ||
450. Delete Node in a BST | ||
701. Insert into a Binary Search Tree 见算法导论 165 | ||
94. Binary Tree Inorder Traversal 用栈实现iterative | ||
230. Kth Smallest Element in a BST 用栈实现inorder遍历 | ||
144. Binary Tree Preorder Traversal | ||
145. Binary Tree Postorder Traversal | 栈的精髓:把 递归中最后处理 的 压在最前面 | |
102. Binary Tree Level Order Traversal 这个一道BFS,和773对比 | ||
107. Binary Tree Level Order Traversal II | ||
513. Find Bottom Left Tree Value | ||
103. Binary Tree Zigzag Level Order Traversal | ||
105. Construct Binary Tree from Preorder and Inorder Traversal 这题不太理解本质 | ||
111. Minimum Depth of Binary Tree | ||
257. Binary Tree Paths | ||
112. Path Sum | ||
113. Path Sum II | ||
437. Path Sum III | ||
124. Binary Tree Maximum Path Sum | ||
Lint-472. Binary Tree Path Sum III 二叉树无向图的构建 | ||
450. Delete Node in a BST 还没做 | ||
938. Range Sum of BST 还没做 | ||
图论 | ||
宽度优先搜索 | 重要:能用BFS做的题,就不要用DFS! | |
200. Number of Islands | ||
Lint-611. Knight Shortest Path 用字典可以记录 见过的点,和对应距离 | ||
133. Clone Graph | ||
297. Serialize and Deserialize Binary Tree 这个题还是有点蒙 | ||
127. Word Ladder | ||
126. Word Ladder II | ||
Lint-794. Sliding Puzzle II | ||
773. Sliding Puzzle 处理二维矩阵的技巧 | ||
102. Binary Tree Level Order Traversal 这个一道BFS,和773对比 | ||
Lint-531. Six Degrees | ||
Lint-573. Build Post Office II | ||
752. Open the Lock | ||
拓扑排序 | ||
207. Course Schedule | ||
210. Course Schedule II | ||
Lint-815. Course Schedule IV 还不会!!! | ||
444. Sequence Reconstruction | ||
Lint-127. Topological Sorting | ||
---- | ||
深度优先搜索 | ||
回溯法 | 在不能继续搜索的点,直接return | |
22. Generate Parentheses | ||
17. Letter Combinations of a Phone Number 回溯法 | ||
46. Permutations | ||
47. Permutations II | ||
60. Permutation Sequence | ||
39. Combination Sum 回溯法 | ||
40. Combination Sum II | ||
78. Subsets | ||
90. Subsets II | ||
51. N-Queens | ||
290. Word Pattern | ||
291. Word Pattern II 回溯 | ||
79. Word Search | ||
294. Flip Game II | ||
--- | ||
490. The Maze | ||
505. The Maze II | 黑色(已经pop出来的,才放seen)不压栈,不压队。Dijkstra是BFS | |
499. The Maze III | ||
733. Flood Fill | ||
547. Friend Circles | ||
695. Max Area of Island | stack,queue,只要append完了,立刻放seen | |
690. Employee Importance | ||
785. Is Graph Bipartite? | 涂颜色 | |
417. Pacific Atlantic Water Flow | ||
542. 01 Matrix | n 不会 | |
721. Accounts Merge | 考察点,把数据转换成图 | |
210. Course Schedule II | ||
630. Course Schedule III | ||
997. Find the Town Judge | ||
407. Trapping Rain Water II 还没做 | ||
743. Network Delay Time | ||
282. Expression Add Operators 这个题好多的边界条件 | ||
301. Remove Invalid Parentheses BFS剪枝 | ||
并查集 | ||
261. Graph Valid Tree | ||
130. Surrounded Regions | ||
128. Longest Consecutive Sequence | ||
Lint-629. Minimum Spanning Tree 最小生成树,Kruskal算法 | ||
684. Redundant Connection | ||
305. Number of Islands II 很重要的并查集的题 | ||
Lint-589. Connecting Graph | ||
Lint-590. Connecting Graph II | ||
Lint-591. Connecting Graph III | ||
Lint-432. Find the Weak Connected Component in the Directed Graph 最后一块没看懂 | ||
721. Accounts Merge | ||
双指针 | ||
287. Find the Duplicate Number 兔子和乌龟 | ||
170. Two Sum III - Data structure design | ||
283. Move Zeroes | ||
26. Remove Duplicates from Sorted Array 兔子乌龟 | ||
344. Reverse String | ||
1. Two Sum 其实这个是哈希表 | ||
167. Two Sum II - Input array is sorted | ||
15. 3Sum | ||
16. 3Sum Closest | ||
18. 4Sum | ||
21. Merge Two Sorted Lists | ||
349. Intersection of Two Arrays | ||
523. Continuous Subarray Sum | ||
Lint-402. Continuous Subarray Sum | ||
Lint-403. Continuous Subarray Sum II | ||
169. Majority Element | ||
229. Majority Element II 摩尔投票算法 | ||
75. Sort Colors 荷兰国旗:很经典的一道题 | ||
Lint-143. Sort Colors II | ||
11. Container With Most Water 装水的题 | ||
42. Trapping Rain Water | 不会 | |
125. Valid Palindrome | ||
986. Interval List Intersections | ||
Lint-839. Merge Two Sorted Interval Lists | ||
滑动窗口 | ||
845. Longest Mountain in Array | 未做 | |
26. Remove Duplicates from Sorted Array | ||
80. Remove Duplicates from Sorted Array II | ||
27. Remove Element | ||
28. Implement strStr() | ||
713. Subarray Product Less Than K | ||
438. Find All Anagrams in a String | ||
159. Longest Substring with At Most Two Distinct Characters | 还没做 | |
340. Longest Substring with At Most K Distinct Characters | 还没做 | |
239. Sliding Window Maximum 可以用堆 | 还没做 | |
480. Sliding Window Median | ||
同向双指针 | ||
209. Minimum Size Subarray Sum | 同向双指针 | |
3. Longest Substring Without Repeating Characters | ||
76. Minimum Window Substring | ||
340. Longest Substring with At Most K Distinct Characters | ||
动态规划 | ||
198. House Robber | ||
213. House Robber II | ||
337. House Robber III | ||
746. Min Cost Climbing Stairs | ||
96. Unique Binary Search Trees | 科特兰数 | |
714. Best Time to Buy and Sell Stock with Transaction Fee | ||
70. Climbing Stairs | ||
276. Paint Fence | ||
368. Largest Divisible Subset | ||
343. Integer Break | ||
583. Delete Operation for Two Strings | ||
877. Stone Game | ||
1140. Stone Game II | ||
记忆化搜索 | ||
139. Word Break | ||
140. Word Break II | ||
Lint-683. Word Break III | ||
九章算法 动态规划: | ||
322. Coin Change 典型 | ||
62. Unique Paths 计数型动态规划 | ||
63. Unique Paths II 坐标型动态规划 | ||
55. Jump Game 存在型动态规划 | ||
152. Maximum Product Subarray | ||
91. Decode Ways 划分型动态规划 | ||
64. Minimum Path Sum 坐标型 (可以用滚动数组节省空间) | ||
361. Bomb Enemy 坐标型 | ||
674. Longest Continuous Increasing Subsequence | ||
329. Longest Increasing Path in a Matrix | ||
338. Counting Bits | ||
序列型动态规划: | ||
Lint-843. Digital Flip | ||
256. Paint House 序列型动态规划 | ||
265. Paint House II | ||
121. Best Time to Buy and Sell Stock | ||
122. Best Time to Buy and Sell Stock II | ||
123. Best Time to Buy and Sell Stock III | ||
188. Best Time to Buy and Sell Stock IV 还没做 | ||
309. Best Time to Buy and Sell Stock with Cooldown | ||
300. Longest Increasing Subsequence | ||
354. Russian Doll Envelopes 是300题的二维问题 | ||
划分型动态规划 | ||
279. Perfect Squares BFS剪枝用set | ||
132. Palindrome Partitioning II | ||
Lint-437. Copy Books | ||
博弈型动态规划 | ||
Lint-394. Coins in a Line | ||
Lint-395. Coins in a Line II | ||
Lint-396. Coins in a Line III | ||
背包型动态规划 --- 背包的总承重通常都需要放在状态里 | ||
Lint-92. Backpack 可行性 | ||
Lint-563. Backpack V 计数型 | ||
Lint-564. Combination Sum IV 计数型 | ||
Lint-125. Backpack II 最值型 | ||
Lint-440. Backpack III 最值型 这一题可以一维数组把空间优化到极致,见视频讲解 | ||
416. Partition Equal Subset Sum | ||
区间型动态规划 | 取头 取尾 | |
516. Longest Palindromic Subsequence 在区间问题中,要按照区间长度的顺序计算 | ||
记忆化搜索,可以大大降低冗余。自上而下 | ||
5. Longest Palindromic Substring | ||
87. Scramble String | ||
312. Burst Balloons 消去型题目 | ||
双序列动态规划 | ||
1143. Longest Common Subsequence | ||
97. Interleaving String | ||
72. Edit Distance | ||
10. Regular Expression Matching | ||
474. Ones and Zeroes | ||
115. Distinct Subsequences | ||
44. Wildcard Matching 还没做 | ||
动态规划难题专场 | ||
221. Maximal Square | ||
639. Decode Ways II 还没做 | ||
Lint-752. Rogue Knight Sven | ||
Lint-971. Surplus Value Backpack 这道题不用掌握 | ||
Lint-89. k Sum | ||
贪心算法 | ||
455. Assign Cookies | ||
435. Non-overlapping Intervals 其实是活动选择问题 | ||
位操作 | ||
29. Divide Two Integers | ||
191. Number of 1 Bits | ||
405. Convert a Number to Hexadecimal 不会 | ||
231. Power of Two | ||
268. Missing Number | ||
397. Integer Replacement 还没做 | ||
371. Sum of Two Integers | ||
172. Factorial Trailing Zeroes 还没做 | ||
260. Single Number III | ||
字符串 | ||
551. Student Attendance Record I | ||
760. Find Anagram Mappings | ||
5. Longest Palindromic Substring | ||
242. Valid Anagram | ||
796. Rotate String | ||
9. Palindrome Number 还没做 | ||
409. Longest Palindrome | ||
266. Palindrome Permutation | ||
267. Palindrome Permutation II | ||
516. Longest Palindromic Subsequence | ||
524. Longest Word in Dictionary through Deleting 还没做 | ||
392. Is Subsequence | ||
648. Replace Words 还没做 | ||
6. ZigZag Conversion | ||
8. String to Integer (atoi) | ||
12. Integer to Roman | ||
13. Roman to Integer | ||
14. Longest Common Prefix | ||
30. Substring with Concatenation of All Words | ||
248. Strobogrammatic Number III | ||
161. One Edit Distance | ||
前缀树 | ||
208. Implement Trie (Prefix Tree) | ||
211. Add and Search Word - Data structure design | ||
212. Word Search II 字典树 | ||
72. Edit Distance | ||
Lint-623. K Edit Distance | ||
425. Word Squares | ||
Question Numbers | ✨ Star ! | Second | Third | Forth | Fifth |
---|---|---|---|---|---|
1-10 | |||||
11-20 | |||||
21-30 |
心得:
- heap 特别适合用于解决有 candidate pool 的问题