Data source: link suggestions and comments are welcome(需要科学上网)
Tree(树)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||
---|---|---|---|---|---|---|---|---|---|
2 | 94 | Binary Tree Inorder Traversal | ★ | 144 | 145 | 429 | 589 | 590 | traversal |
3 | 987 | 1302 | |||||||
4 | 100 | Same Tree | ★★ | 101 | 104 | 110 | 111 | 572 | |
5 | 965 | ||||||||
6 | 102 | Binary Tree Level Order Traversal | ★★ | 107 | 429 | 872 | collecting nodes | ||
7 | 814 | Binary Tree Pruning | ★★★ | 669 | 1325 | ||||
8 | 112 | Path Sum | ★★★ | 113 | 437 | ||||
9 | 129 | Sum Root to Leaf Numbers | ★★★ | 257 | |||||
10 | 236 | ★★★ | 235 | ||||||
11 | 297 | Serialize and Deserialize Binary Tree | ★★★ | 449 | |||||
12 | 508 | Most Frequent Subtree Sum | ★★★ | ||||||
13 | 124 | Binary Tree Maximum Path Sum | ★★★ | 543 | 687 | Use both children, return one | |||
14 | 968 | Binary Tree Cameras | ★★★★ | 337 | 979 |
Divide and conquer(分治)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||
---|---|---|---|---|---|---|---|---|---|
2 | 169 | Majority Element | ★★ | 你知道茴香豆的茴有几种写法吗? | |||||
3 | 153 | Find Minimum in Rotated Sorted Array | ★★ | 154 | |||||
4 | 912 | Sort and Array | ★★★ | merge sort | |||||
5 | 315 | Count of Smaller Numbers After Self | ★★★★ | merge sort / BIT |
List(链表)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
2 | 2 | Add Two Numbers | ★★ | 445 | traversal | ||||||
3 | 24 | Swap Nodes in Pairs | ★★ | reverse | |||||||
4 | 206 | Reverse Linked List | ★★ | reverse | |||||||
5 | 141 | Linked List Cycle | ★★ | 142 | fast/slow | ||||||
6 | 23 | Merge k Sorted Lists | ★★★ | 21 | priority_queue / mergesort | ||||||
7 | 147 | Insertion Sort List | ★★★ | insertion sort | |||||||
8 | 148 | Sort List | ★★★★ | merge sort O(1) space | |||||||
9 | 707 | Design Linked List | ★★★★ |
BST(二叉搜索树)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||
---|---|---|---|---|---|---|---|---|---|
2 | 98 | Validate Binary Search Tree | ★★ | 530 | inorder | ||||
3 | 700 | Search in a Binary Search Tree | ★★ | 701 | binary search | ||||
4 | 230 | Kth Smallest Element in a BST | ★★★ | inorder | |||||
5 | 99 | Recover Binary Search Tree | ★★★ | inorder | |||||
6 | 108 | ★★★ | build BST | ||||||
7 | 501 | Find Mode in Binary Search Tree | ★★★ | inorder | |||||
8 | 450 | Delete Node in a BST | ★★★★ | binary search |
Graph(图论)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||
---|---|---|---|---|---|---|---|---|---|
2 | 133 | Clone Graph | ★★ | 138 | queue + hashtable | ||||
3 | 200 | Number of Islands | ★★ | 547 | 695 | 733 | 827 | 1162 | grid + connected components |
4 | 841 | Keys and Rooms | ★★ | 1202 | DFS, connected components | ||||
5 | 207 | Course Schedule | ★★★ | 210 | 802 | topology sorting | |||
6 | 399 | Evaluate Division | ★★★ | 839 | 952 | 990 | 721 | 737 | union find |
7 | 785 | Is Graph Bipartite? | ★★★ | 886 | 1042 | bipartition, graph coloring | |||
8 | 997 | Find the Town Judge | ★★★ | in/out degrees | |||||
9 | 433 | Minimum Genetic Mutation | ★★★ | 815 | 863 | 1129 | 1263 | unweighted shortest path / BFS | |
10 | 684 | Redundant Connection | ★★★★ | 685 | 1319 | cycle, union find | |||
11 | 743 | Network Delay Time | ★★★★ | 787 | 882 | 924 | 1334 | weighted shortest path | |
12 | 847 | ★★★★ | 864 | 1298 | BFS | ||||
13 | 332 | Reconstruct Itinerary | ★★★★ | Eulerian path | |||||
14 | 1192 | ★★★★ | Tarjan | ||||||
15 | 943 | Find the Shortest Superstring | ★★★★★ | 980 | 996 | Hamiltonian path (DFS / DP) | |||
16 | 959 | Regions Cut By Slashes | ★★★★★ | union find / grid + CCs |
Search (BFS/DFS)(搜索/回溯)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
2 | 17 | Letter Combinations of a Phone Number | ★★ | 39 | 40 | 77 | 78 | 90 | 216 | Combination | |
3 | 46 | Permutations | ★★ | 47 | 784 | 943 | 996 | Permutation | |||
4 | 22 | Generate Parentheses | ★★★ | 301 | DFS | ||||||
5 | 37 | Sudoku Solver | ★★★ | 51 | 52 | DFS | |||||
6 | 79 | Word Search | ★★★ | 212 | DFS | ||||||
7 | 127 | Word Ladder | ★★★★ | 126 | 752 | 818 | BFS | ||||
8 | 542 | 01 Matrix | ★★★ | 675 | 934 | BFS | |||||
9 | 698 | Partition to K Equal Sum Subsets | ★★★ | 93 | 131 | 241 | 282 | 842 | Partition |
Binary Search(二分搜索)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
2 | 35 | Search Insert Position | ★★ | 34 | 704 | 981 | upper_bound | ||||
3 | 33 | Search in Rotated Sorted Array | ★★★ | 81 | 153 | 154 | 162 | 852 | rotated / peak | ||
4 | 69 | Sqrt(x) | ★★★ | upper_bound | |||||||
5 | 74 | Search a 2D Matrix | ★★★ | treat 2d as 1d | |||||||
6 | 875 | Koko Eating Bananas | ★★★ | 1011 | guess ans and check | ||||||
7 | 4 | Median of Two Sorted Arrays | ★★★★ | ||||||||
8 | 378 | ★★★★ | 668 | kth + matrix | |||||||
9 | 719 | Find K-th Smallest Pair Distance | ★★★★ | 786 | kth + two pointers |
Two Pointers(双指针)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
2 | 11 | Container With Most Water | ★★ | 42 | |||||||
3 | 125 | Valid Palindrome | ★★ | 455 | |||||||
4 | 917 | Reverse Only Letters | ★★ | 925 | 986 | 855 | |||||
5 | 167 | ★★★ | 15 | 16 | |||||||
6 | 977 | Squares of a Sorted Array | ★★ | merge sort | |||||||
7 | 992 | ★★★★ |
Advanced(高级)
1 | Id | Name | Difficulty | Similar Problems | Comments | |||||
---|---|---|---|---|---|---|---|---|---|---|
2 | 208 | ★★★ | 648 | 676 | 677 | 720 | 745 | 211 | Trie | |
3 | 307 | ★★★ | BIT/Segment Tree | |||||||
4 | 901 | Online Stock Span | ★★★ | 907 | 1019 | monotonic stack | ||||
5 | 239 | Sliding Window Maximum | ★★★ | monotonic queue |
DP(动态规划)
1 | Id | Name | Difficulty | Similar Problems | Comments | ||||
---|---|---|---|---|---|---|---|---|---|
2 | 70 | Climbing Stairs | ★ | 746 | 1137 | I: O(n), S = O(n), T = O(n) | |||
3 | 303 | Range Sum Query – Immutable | ★ | 1218 | |||||
4 | 53 | Maximum Subarray | ★★ | 121 | |||||
5 | 62 | Unique Paths | ★★ | 63 | 64 | 120 | 174 | 931 | I: O(mn), S = O(mn), T = O(mn) |
6 | 1210 | ||||||||
7 | 85 | Maximal Rectangle | ★★★ | 221 | 304 | 1277 | |||
8 | 198 | House Robber | ★★★ | 213 | 309 | 740 | 790 | 801 | I: O(n), S = O(3n), T = O(3n) |
9 | 279 | Perfect Squares | ★★★ | I: n, S = O(n), T = O(n*sqrt(n)) | |||||
10 | 139 | Word Break | ★★★ | 140 | 818 | I: O(n), S = O(n), T = O(n^2) | |||
11 | 300 | Longest Increasing Subsequence | ★★★ | 673 | 1048 | ||||
12 | 96 | Unique Binary Search Trees | ★★★ | ||||||
13 | 1105 | Filling Bookcase Shelves | ★★★ | I: O(n) + t, S = O(n), T = O(n^2) | |||||
14 | 131 | Palindrome Partitioning | ★★★ | 89 | I: O(n), S = O(2^n), T = O(2^n) | ||||
15 | 72 | Edit Distance | ★★★ | 10 | 44 | 97 | 115 | 583 | I: O(m+n), S = O(mn), T = O(mn) |
16 | 712 | 1187 | 1143 | 1092 | 718 | ||||
17 | 1139 | Largest 1-Bordered Square | ★★★ | I: O(mn), S = O(mn) T = O(mn*min(n,m)) | |||||
18 | 688 | Knight Probability in Chessboard | ★★★ | 576 | 935 | I: O(mn) + k S = O(kmn), T = O(kmn) | |||
19 | 322 | Coin Change | ★★★ | 377 | 416 | 494 | 1043 | 1049 | I: O(n) + k, S = O(n), T = O(kn) |
20 | 1220 | 1230 | 1262 | 1269 | |||||
21 | 813 | Largest Sum of Averages | ★★★★ | 1278 | 1335 | 410 | I: O(n) + k S = O(n*k), T = O(kn^2) | ||
22 | 1223 | Dice Roll Simulation | ★★★★ | I: O(n) + k + p S = O(k*p), T = O(n^2kp) | |||||
23 | 312 | Burst Balloons | ★★★★ | 664 | 1024 | 1039 | 1140 | 1130 | I: O(n), S = O(n^2), T = O(n^3) |
24 | 741 | Cherry Pickup | ★★★★ | I: O(n^2), S = O(n^3), T = O(n^3) | |||||
25 | 546 | Remove Boxes | ★★★★★ | I: O(n), S = O(n^3), T = O(n^4) | |||||
26 | 943 | Find the Shortest Superstring | ★★★★★ | 980 | 996 | 1125 | I: O(n) S = O(n*2^n), T = (n^2*2^n) |
请尊重作者的劳动成果,转载请注明出处!花花保留对文章/视频的所有权利。
如果您喜欢这篇文章/视频,欢迎您捐赠花花。
If you like my articles / videos, donations are welcome.