题目分类 和答案来自
https://github.com/kamyu104/LeetCode-Solutions/blob/master/0001-1000.md#array
Solutions(现在是1-1000)
每一个topic 划分出独立界面 每一个专题轮流做
Bit manipulation
Array
String
Linked List
Stack
Queue
Binary Heap
Tree
Hash Table
Math
Sort
Two Pointers
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Recursion
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Binary Search
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| 0004 | Median of Two Sorted Arrays | C++ Python | O(log(min(m, n))) | O(1) | Hard | | |
| 0033 | Search in Rotated Sorted Array | C++ Python | O(logn) | O(1) | Medium | CTCI | |
| 0034 | Find First and Last Position of Element in Sorted Array | C++ Python | O(logn) | O(1) | Medium | | |
| 0035 | Search Insert Position | C++ Python | O(logn) | O(1) | Medium | | |
| 0069 | Sqrt(x) | C++ Python | O(logn) | O(1) | Medium | | |
| 0074 | Search a 2D Matrix | C++ Python | O(logm + logn) | O(1) | Medium | | |
| 0081 | Search in Rotated Sorted Array II | C++ Python | O(logn) ~ O(n) | O(1) | Medium | CTCI | |
| 0153 | Find Minimum in Rotated Sorted Array | C++ Python | O(logn) | O(1) | Medium | | |
| 0154 | Find Minimum in Rotated Sorted Array II | C++ Python | O(logn) ~ O(n) | O(1) | Hard | | |
| 0162 | Find Peak Element | C++ Python | O(logn) | O(1) | Medium | | |
| 0222 | Count Complete Tree Nodes | C++ Python | O((logn)^2) | O(1) | Medium | | |
| 0275 | H-Index II | C++ Python | O(logn) | O(1) | Medium | | Binary Search |
| 0278 | First Bad Version | C++ Python | O(logn) | O(1) | Easy | LintCode | |
| 0300 | Longest Increasing Subsequence | C++ Python | O(nlogn) | O(n) | Medium | CTCI, LintCode | Binary Search, BIT, Fenwick Tree, Segment Tree, DP |
| 0302 | Smallest Rectangle Enclosing Black Pixels | C++ Python | O(nlogn) | O(1) | Hard | 🔒 | |
| 0354 | Russian Doll Envelopes | C++ Python | O(nlogn) | O(1) | Hard | | |
| 0363 | Max Sum of Rectangle No Larger Than K | C++ Python | O(min(m, n)^2 * max(m, n) * logn(max(m, n))) | O(max(m, n)) | Hard | | |
| 0367 | Valid Perfect Square | C++ Python | O(logn) | O(1) | Medium | | |
| 0374 | Guess Number Higher or Lower | C++ Python | O(logn) | O(1) | Easy | | |
| 0410 | Split Array Largest Sum | C++ Python | O(nlogs) | O(1) | Hard | | |
| 0436 | Find Right Interval | C++ Python | O(nlogn) | O(n) | Medium | | |
| 0475 | Heaters | C++ Python | O((m + n) * logn) | O(1) | Easy | | |
| 0540 | Single Element in a Sorted Array | C++ Python | O(logn) | O(1) | Medium | | |
| 0658 | Find K Closest Elements | C++ Python | O(logn + k) | O(1) | Medium | | |
| 0668 | Kth Smallest Number in Multiplication Table | C++ Python | O(m * log(m * n)) | O(1) | Hard | | |
| 0702 | Search in a Sorted Array of Unknown Size | C++ Python | O(logn) | O(1) | Medium | 🔒 | Binary Search |
| 0704 | Binary Search | C++ Python | O(logn) | O(1) | Easy | | Binary Search |
| 0710 | Random Pick with Blacklist | C++ Python | ctor: O(b) pick: O(1) | O(b) | Hard | | |
| 0719 | Find K-th Smallest Pair Distance | C++ Python | O(nlogn + nlogw) | O(1) | Hard | | |
| 0744 | Find Smallest Letter Greater Than Target | C++ Python | O(logn) | O(1) | Easy | | |
| 0774 | Minimize Max Distance to Gas Station | C++ Python | O(nlogr) | O(1) | Hard | | |
| 0786 | K-th Smallest Prime Fraction | C++ Python | O(nlogr) | O(1) | Hard | | |
| 0793 | Preimage Size of Factorial Zeroes Function | C++ Python | O((logn)^2) | O(1) | Hard | | |
| 0852 | Peak Index in a Mountain Array | C++ Python | O(logn) | O(1) | Easy | | |
| 0875 | Koko Eating Bananas | C++ Python | O(nlogr) | O(1) | Medium | | |
| 0878 | Nth Magical Number | C++ Python | O(logn) | O(1) | Hard | | |
| 0894 | All Possible Full Binary Trees | C++ Python | O(n * 4^n / n^(3/2)) | O(n * 4^n / n^(3/2)) | Medium | | |
| 0911 | Online Election | C++ Python | ctor: O(n) query : O(logn) | O(n) | Medium | | |
| 0981 | Time Based Key-Value Store | C++ Python | set: O(1) get : O(logn) | O(n) | Medium | | |
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Binary Search Tree
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Breadth-First Search
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Depth-First Search
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| 0112 | Path Sum | Python | O(n) | O(h) | Easy | | |
| 0113 | Path Sum II | Python | O(n) | O(h) | Medium | | |
| 0199 | Binary Tree Right Side View | Python | O(n) | O(h) | Medium | | |
| 0200 | Number of Islands | C++ Python | O(m * n) | O(m * n) | Medium | | BFS, DFS, Union Find |
| 0236 | Lowest Common Ancestor of a Binary Tree | C++ Python | O(n) | O(h) | Medium | EPI | |
| 0247 | Strobogrammatic Number II | C++ Python | O(n * 5^(n/2)) | O(n) | Medium | 🔒 | |
| 0250 | Count Univalue Subtrees | C++ Python | O(n) | O(h) | Medium | 🔒 | |
| 0257 | Binary Tree Paths | C++ Python | O(n * h) | O(h) | Easy | | |
| 0282 | Expression Add Operators | C++ Python | O(4^n) | O(n) | Hard | | |
| 0301 | Remove Invalid Parentheses | C++ Python | O(C(n, c)) | O(c) | Hard | | |
| 0329 | Longest Increasing Path in a Matrix | C++ Python | O(m * n) | O(m * n) | Hard | | DFS, Topological Sort |
| 0339 | Nested List Weight Sum | C++ Python | O(n) | O(h) | Easy | 🔒 | |
| 0364 | Nested List Weight Sum II | C++ Python | O(n) | O(h) | Medium | 🔒 | |
| 0366 | Find Leaves of Binary Tree | C++ Python | O(n) | O(h) | Medium | 🔒 | |
| 0417 | Pacific Atlantic Water Flow | C++ Python | O(m * n) | O(m * n) | Medium | | |
| 0440 | K-th Smallest in Lexicographical Order | C++ Python | O(logn) | O(logn) | Hard | | |
| 0464 | Can I Win | C++ Python | O(n!) | O(n) | Medium | | |
| 0515 | Find Largest Value in Each Tree Row | C++ Python | O(n) | O(h) | Medium | | |
| 0547 | Friend Circles | C++ Python | O(n^2) | O(n) | Medium | | Union Find |
| 0582 | Kill Process | C++ Python | O(n) | O(n) | Medium | 🔒 | DFS, BFS |
| 0638 | Shopping Offers | C++ Python | O(n * 2^n) | O(n) | Medium | | |
| 0690 | Employee Importance | C++ Python | O(n) | O(h) | Easy | | DFS, BFS |
| 0694 | Number of Distinct Islands | C++ Python | O(m * n) | O(m * n) | Medium | 🔒 | |
| 0695 | Max Area of Island | C++ Python | O(m * n) | O(m * n) | Easy | | |
| 0711 | Number of Distinct Islands II | C++ Python | O((m * n) * log(m * n)) | O(m * n) | Hard | 🔒 | Hash |
| 0733 | Max Area of Island | C++ Python | O(m * n) | O(m * n) | Easy | | |
| 0749 | Contain Virus | C++ Python | O((m * n)^(4/3)) | O(m * n) | Hard | | Simulation |
| 0753 | Cracking the Safe | C++ Python | O(k^n) | O(k^n) | Hard | | de Bruijn sequences, Lyndon word, Rolling Hash, Backtracking, Greedy |
| 0756 | Pyramid Transition Matrix | C++ Python | O(a^b) | O(a^b) | Medium | | |
| 0785 | Is Graph Bipartite? | C++ Python | *O( | V | + | E | )* |
| 0797 | All Paths From Source to Target | C++ Python | O(p + r * n) | O(n) | Medium | | |
| 0802 | Find Eventual Safe States | C++ Python | *O( | V | + | E | )* |
| 0827 | Making A Large Island | C++ Python | O(n^2) | O(n^2) | Hard | | |
| 0834 | Sum of Distances in Tree | C++ Python | O(n) | O(n) | Hard | | |
| 0841 | Keys and Rooms | C++ Python | O(n!) | O(n) | Medium | | |
| 0851 | Loud and Rich | C++ Python | O(q + r) | O(q + r) | Medium | | |
<b><a href="#algorithms">⬆️ Back to Top</a></b>
专题1 → Backtracking
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Dynamic Programming
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Greedy
<b><a href="#algorithms">⬆️ Back to Top</a></b>
Graph