Up to date, there are total 154 problems on LeetCode Online Judge. The number of problems is increasing recently. Here is the classification of all 154 problems. I'll keep updating for full summary and better solutions. Stay tuned for updates.
- Bit Manipulation
- Array
- String
- Linked List
- Stack
- Heap
- Tree
- Graph
- Hash Table
- Data Structure
- Math
- Two Pointer
- Sort
- Brute Force Search
- Divide and Conquer
- Binary Search
- Breadth-First Search
- Depth-First Search
- Dynamic Programming
- Backtracking
- Greedy
##Bit Manipulation
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
##Array
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| 3 Sum | 3sum.py | O(n^2) | O(1) | Medium | |
| 3 Sum Closest | 3sum-closest.py | O(n^2) | O(1) | Medium | |
| 4 Sum | 4sum.py | O(n^2) ~ O(n^4) | O(n^2) | Medium | |
| Best Time to Buy and Sell Stock | best-time-to-buy-and-sell-stock.py | O(n) | O(1) | Medium | |
| First Missing Positive | first-missing-positive.py | O(n) | O(1) | Hard | |
| Longest Consecutive Sequence | longest-consecutive-sequence.py | O(n) | O(n) | Easy | Tricky |
##String
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Add Binary | add-binary.py | O(n) | O(1) | Easy | |
| Anagrams | anagrams.py | O(n) | O(n) | Medium | |
| Count and Say | count-and-say.py | O(n^2) | O(n) | Easy | |
| Implement strStr() | implement-strstr.py | O(n + m) | O(m) | Easy | KMP Algorithm |
| Length of Last Word | length-of-last-word.py | O(n) | O(1) | Easy | |
| Longest Common Prefix | longest-common-prefix.py | O(n1 + n2 + ...) | O(1) | Easy | |
| Longest Palindromic Substring | longest-palindromic-substring.py | O(n) | O(n) | Medium | Manacher's Algorithm |
##Linked List
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Add Two Numbers | add-two-numbers.py | O(n) | O(1) | Medium | |
| Copy List with Random Pointer | copy-list-with-random-pointer.py | O(n) | O(1) | Hard |
##Stack
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Evaluate Reverse Polish Notation | evaluate-reverse-polish-notation.py | O(n) | O(n) | Medium | |
| Longest Valid Parentheses | longest-valid-parentheses.py | O(n) | O(1) | Hard |
##Heap
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
##Tree
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Binary Tree Preorder Traversal | binary-tree-preorder-traversal.py | O(n) | O(n) | Medium | |
| Binary Tree Inorder Traversal | binary-tree-inorder-traversal.py | O(n) | O(n) | Medium | |
| Binary Tree Postorder Traversal | binary-tree-postorder-traversal.py | O(n) | O(n) | Hard |
---
##Graph
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
##Hash Table
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Longest Substring Without Repeating Characters | longest-substring-without-repeating-characters.py | O(n) | O(1) | Medium | |
| Max Points on a Line | max-points-on-a-line.py | O(n^2) | O(n) | hard |
##Data Structure
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| LRU Cache | lru-cache.py | O(1) | O(n) | Hard |
##Math
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Gray Code | gray-code.py | O(2^n) | O(1) | Medium | |
| Integer to Roman | integer-to-roman.py | O(n) | O(1) | Medium |
##Sort
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Insert Interval | insert-interval.py | O(n) | O(1) | Hard | |
| Insertion Sort List | insertion-sort-list.py | O(n^2)) | O(1) | Medium |
##Two Pointer
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Linked List Cycle | linked-list-cycle.py | O(n) | O(1) | Medium | |
| Linked List Cycle II | linked-list-cycle-ii.py | O(n) | O(1) | Medium |
##Brute Force Search
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Letter Combinations of a Phone Number | letter-combinations-of-a-phone-number.py | O(4^n) | O(1) | Medium |
##Divide and Conquer
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Construct Binary Tree from Inorder and Postorder Traversal | construct-binary-tree-from-inorder-and-postorder-traversal.py | O(n) | O(n) | Medium | |
| Construct Binary Tree from Preorder and Inorder Traversal | construct-binary-tree-from-preorder-and-inorder-traversal.py | O(n) | O(n) | Medium | |
| Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree.py | O(n) | O(logn) | Medium | |
| Convert Sorted List to Binary Search Tree | convert-sorted-list-to-binary-search-tree.py | O(n) | O(logn) | Medium | |
| Flatten Binary Tree to Linked List | flatten-binary-tree-to-linked-list.py | O(n) | O(logn) | Medium | |
| Maximum Depth of Binary Tree | maximum-depth-of-binary-tree.py | O(n) | O(logn) | Easy |
##Binary Search
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Search in Rotated Sorted Array | find-minimum-in-rotated-sorted-array.py | O(logn) | O(1) | Medium | |
| Search in Rotated Sorted Array II | find-minimum-in-rotated-sorted-array-ii.py | O(logn) ~ O(n) | O(1) | Hard |
##Breadth-First Search
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Binary Tree Level Order Traversal | binary-tree-level-order-traversal.py | O(n) | O(n) | Easy | |
| Binary Tree Level Order Traversal II | binary-tree-level-order-traversal-ii.py | O(n) | O(n) | Easy | |
| Binary Tree Zigzag Level Order Traversal | binary-tree-zigzag-level-order-traversal.py | O(n) | O(n) | Medium | |
| Clone Graph | clone-graph.py | O(n) | O(n) | Medium |
##Depth-First Search
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Balanced Binary Tree | balanced-binary-tree.py | O(n) | O(logn) | Easy | |
| Binary Tree Maximum Path Sum | binary-tree-maximum-path-sum.py | O(n) | O(logn) | Hard | |
| Combination Sum | combination-sum.py | O(n^m) | O(m) | Medium | |
| Combination Sum II | combination-sum-ii.py | O(n! / m!(n-m)!) | O(m) | Medium | |
| Combinations | combinations.py | O(n!) | O(n) | Medium | |
| Generate Parentheses | generate-parentheses.py | O(4^n / n^(3/2)) | O(n) | Medium |
##Dynamic Programming
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Best Time to Buy and Sell Stock III | best-time-to-buy-and-sell-stock-iii.py | O(n) | O(1) | Hard | |
| Climbing Stairs | climbing-stairs.py | O(n) | O(1) | Easy | |
| Decode Ways | decode-ways.py | O(n) | O(1) | Medium | |
| Distinct Subsequences | distinct-subsequences.py | O(n^2) | O(n) | Medium | |
| Edit Distance | edit-distance.py | O(n * m) | O(n + m) | Medium | |
| Interleaving String | interleaving-string.py | O(n * m) | O(n + m) | Hard | |
| Maximal Rectangle | maximal-rectangle.py | O(n^2) | O(n) | Hard | |
| Maximum Product Subarray | maximum-product-subarray.py | O(n) | O(1) | Medium | |
| Maximum Subarray | maximum-subarray.py | O(n) | O(1) | Medium |
##Backtracking
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
##Greedy
| Problem | Solution | Time | Space | Difficulty | Notes |
|---|---|---|---|---|---|
| Best Time to Buy and Sell Stock II | best-time-to-buy-and-sell-stock-ii.py | O(n) | O(1) | Medium | |
| Candy | candy.py | O(n) | O(n) | Hard | |
| Container With Most Water | container-with-most-water.py | O(n) | O(1) | Medium | |
| Gas Station | gas-station.py | O(n) | O(1) | Medium | |
| Jump Game | jump-game.py | O(n) | O(1) | Medium | |
| Jump Game II | jump-game-ii.py | O(n^2) | O(1) | Hard | |
| Largest Rectangle in Histogram | largest-rectangle-in-histogram.py | O(n) | O(n) | Hard | Tricky |