[LintCode]——目录
Yet Another Source Code for LintCode
Current Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10)
For more problems and solutions, you can see my LintCode repository.
I'll keep updating for full summary and better solutions. See cnblogs to get details or click problem's Note directly. Tip means has been added tips and sketch (* means has note at cnblogs).
This context template fork from kamyu104 , thanks them very much!
Algorithms
- Array
- Backtracking
- Binary Search
- Binary Search Trees
- Bit Manipulation
- Breadth-First Search
- Data Structure
- Depth-First Search
- Dynamic Programming
- Greedy
- Hash Tables
- Heap
- Linked List
- Math
- OO Design
- Queue
- Recursion
- Sort
- Stack
- String
- System Design
- Tree
Array
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 6 | Merge Sorted Array | C++ | O(m+n) | O(1) | Easy | LeetCode | Tip |
| 8 | Rotate String | C++ | O(n) | O(1) | Easy | LeetCode | Tip |
| 9 | Fizz Buzz | C++ | O(n) | O(1) | Easy | Tip |
|
| 30 | Insert Interval | C++ | O(n) | O(1) | Easy | LeetCode, EPI | Tip |
| 31 | Partition Array | C++ | O(n) | O(1) | Medium | Tip Two Pointers |
|
| 32 | Minimum Window Substring | C++ | O(n) | O(1) | Medium | LeetCode | todo |
| 38 | Search a 2D Matrix II | C++ | O(m+n) | O(1) | Medium | EPI | Tip |
| 39 | Recover Rotated Sorted Array | C++ | O(n) | O(1) | Easy | ||
| 46 | Majority Number | C++ | O(n) | O(1) | Easy | LeetCode | Tip |
| 47 | Majority Number II | C++ | O(n) | O(1) | Medium | EPI | |
| 48 | Majority Number III | C++ | O(n) | O(k) | Medium | EPI | |
| 49 | Sort Letters by Case | C++ | O(n) | O(1) | Medium | Two Pointers | |
| 50 | Product of Array Exclude Itself | C++ | O(n) | O(1) | Easy | ||
| 51 | Previous Permutation | C++ | O(n) | O(1) | Medium | ||
| 52 | Next Permutation | C++ | O(n) | O(1) | Medium | LeetCode | |
| 57 | 3 Sum | C++ | O(n^2 ) | O(1) | Medium | LeetCode | Two Pointers, Sort |
| 58 | 4 Sum | C++ | O(n^3 ) | O(1) | Medium | LeetCode | todo |
| 59 | 3 Sum Closest | C++ | O(n^2 ) | O(1) | Medium | LeetCode | Two Pointers, Sort |
| 64 | Merge Sorted Array II | C++ | O(m+n) | O(1) | Easy | LeetCode | todo |
| 100 | Remove Duplicates from Sorted Array | C++ | O(n) | O(1) | Easy | LeetCode | Two Pointers |
| 101 | Remove Duplicates from Sorted Array II | C++ | O(n) | O(1) | Easy | LeetCode | Two Pointers |
| 133 | Longest Words | C++ | O(n) | O(n) | Easy | ||
| 144 | Interleaving Positive and Negative Numbers | C++ | O(n) | O(1) | Medium | Two Pointers | |
| 161 | Rotate Image | C++ | O(n^2 ) | O(1) | Medium | LeetCode | |
| 162 | Set Matrix Zeroes | C++ | _O(m*n)_ | O(1) | Medium | LeetCode | |
| 172 | Remove Element | C++ | O(n) | O(1) | Easy | LeetCode | Two Pointers |
| 185 | Matrix Zigzag Traversal | C++ | _O(m*n)_ | O(1) | Easy | todo | |
| 189 | First Missing Positive | C++ | O(n) | O(1) | Easy | LeetCode, EPI | Hash |
| 190 | Next Permutation II | C++ | O(n) | O(1) | Medium | LeetCode | |
| 200 | Longest Palindromic Substring | C++ | O(n) | O(n) | Medium | LeetCode | Manacher's Algorithm |
| 363 | Trapping Rain Water | C++ | O(n) | O(1) | Medium | LeetCode | Two Pointers, Tricky |
| 373 | Partition Array by Odd and Even | C++ | O(n) | O(1) | Easy | Two Pointers | |
| 374 | Spiral Matrix | C++ | _O(m*n)_ | O(1) | Medium | LeetCode | |
| 381 | Spiral Matrix II | C++ | O(n^2 ) | O(1) | Medium | LeetCode | todo |
| 382 | Triangle Count | C++ | O(n^2 ) | O(1) | Medium | todo | |
| 383 | Container With Most Water | C++ | O(n) | O(1) | Medium | LeetCode, EPI | Two Pointers |
| 388 | Permutation Sequence | C++ | O(n^2 ) | O(n) | Medium | LeetCode | |
| 389 | Valid Sudoku | C++ | O(9^2 ) | O(9) | Easy | LeetCode | |
| 404 | Subarray Sum II | C++ | O(nlogn) | O(n) | Hard | todo | |
| 405 | Submatrix Sum | C++ | _O(m*n^2 )_ | O(m) | Hard | todo | |
| 406 | Minimum Size Subarray Sum | C++ | O(n) | O(1) | Medium | LeetCode | Two Pointers, Binary Search |
| 539 | Move Zeroes | C++ | O(n) | O(1) | Easy | LeetCode | Two Pointers |
Backtracking
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 15 | Permutations | C++ | _O(n*n!)_ | O(n) | Medium | LeetCode, EPI | |
| 16 | Permutations II | C++ | _O(n*n!)_ | O(n) | Medium | LeetCode, EPI | |
| 17 | Subsets | C++ | _O(n*2^n )_ | O(1) | Medium | LeetCode | |
| 18 | Subsets II | C++ | _O(n*2^n )_ | O(1) | Medium | LeetCode | |
| 33 | N-Queens | C++ | _O(n*n!)_ | O(n) | Medium | LeetCode, EPI | |
| 34 | N-Queens II | C++ | _O(n*n!)_ | O(n) | Medium | LeetCode, EPI | |
| 123 | Word Search | C++ | O(mnl) | O(l) | Medium | LeetCode | todo |
| 132 | Word Search II | C++ | O(mnl) | O(l) | Hard | Trie, DFS | |
| 135 | Combination Sum | C++ | _O(k*n^k )_ | O(k) | Medium | LeetCode | DFS |
| 136 | Palindrome Partitioning | C++ | O(2^n ) | O(n) | Easy | LeetCode, EPI | |
| 152 | Combinations | C++ | _O(k*n^k )_ | O(k) | Medium | LeetCode, EPI | |
| 153 | Combination Sum II | C++ | _O(k*C(n,k))_ | O(k) | Medium | LeetCode | DFS |
| 425 | Letter Combinations of a Phone Number | C++ | _O(n*4^n )_ | O(n) | Medium | LeetCode | |
| 426 | Restore IP Addresses | C++ | O(1) | O(1) | Medium | LeetCode | |
| 427 | Generate Parentheses | C++ | O(4^n / n^(3/2) ) | O(n) | Medium | LeetCode | todo |
Binary Search
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 14 | First Position of Target | C++ | O(logn) | O(1) | Easy | ||
| 28 | Search a 2D Matrix | C++ | O(logm + logn) | O(1) | Easy | LeetCode | |
| 60 | Search Insert Position | C++ | O(logn) | O(1) | Easy | LeetCode | |
| 61 | Search for a Range | C++ | O(logn) | O(1) | Medium | LeetCode | |
| 62 | Search in Rotated Sorted Array | C++ | O(logn) | O(1) | Medium | LeetCode | |
| 63 | Search in Rotated Sorted Array II | C++ | O(logn) | O(1) | Medium | LeetCode | |
| 65 | Median of two Sorted Arrays | C++ | O(log(min(m,n))) | O(1) | Hard | LeetCode, EPI | todo |
| 74 | First Bad Version | C++ | O(logn) | O(1) | Medium | ||
| 75 | Find Peak Element | C++ | O(logn) | O(1) | Medium | LeetCode | |
| 76 | Longest Increasing Subsequence | C++ | O(nlogn) | O(n) | Medium | CTCI | |
| 141 | Sqrt(x) | C++ | O(logn) | O(1) | Easy | LeetCode | |
| 159 | Find Minimum in Rotated Sorted Array | C++ | O(logn) | O(1) | Medium | LeetCode | |
| 160 | Find Minimum in Rotated Sorted Array II | C++ | O(logn) | O(1) | Medium | LeetCode | |
| 183 | Wood Cut | C++ | O(nlogL) | O(1) | Medium | ||
| 390 | Find Peak Element II | C++ Java | O(m+n) | O(1) | Hard | todo | |
| 437 | Copy Books | C++ | O(nlogp) | O(1) | Hard | UVa 714 | todo |
Binary Search Trees
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 11 | Search Range in Binary Search Tree | C++ | O(n) | O(h) | Medium | EPI | |
| 86 | Binary Search Tree Iterator | C++ | O(1) | O(h) | Hard | LeetCode | |
| 87 | Remove Node in Binary Search Tree | C++ | O(h) | O(h) | Hard | todo | |
| 249 | Count of Smaller Number before itself | C++ | O(nlogn) | O(n) | Hard | BST, BIT, Divide and Conquer, Merge Sort | |
| 360 | Sliding Window Median | C++ | O(nlogw) | O(w) | Hard | todo | |
| 391 | Number of Airplanes in the Sky | C++ | O(nlogn) | O(n) | Easy | BST, Heap | |
| 401 | Kth Smallest Number in Sorted Matrix | C++ | O(klog(min(m,n,k))) | O(min(m,n,k)) | Medium | BST, Heap |
Bit Manipulation
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 1 | A + B Problem | C++ | O(1) | O(1) | Medium | ||
| 82 | Single Number | C++ | O(n) | O(1) | Easy | LeetCode | |
| 83 | Single Number II | C++ | O(n) | O(1) | Easy | LeetCode | |
| 84 | Single Number III | C++ | O(n) | O(1) | Medium | CTCI | |
| 142 | O(1) Check Power of 2 | C++ | O(1) | O(1) | Easy | ||
| 179 | Update Bits | C++ | O(1) | O(1) | Medium | CTCI | |
| 181 | Flip Bits | C++ | O(1) | O(1) | Easy | CTCI | |
| 196 | Find the Missing Number | C++ | O(n) | O(1) | Medium | ||
| 365 | Count 1 in Binary | C++ | O(1) | O(1) | Easy | CTCI |
Breadth-First Search
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 69 | Binary Tree Level Order Traversal | C++ | O(n) | O(n) | Medium | LeetCode | BFS |
| 70 | Binary Tree Level Order Traversal II | C++ | O(n) | O(n) | Medium | LeetCode | BFS |
| 71 | Binary Tree Zigzag Level Order Traversal | C++ | O(n) | O(n) | Medium | LeetCode | BFS |
| 120 | Word Ladder | C++ | _O(n*d)_ | O(d) | Medium | LeetCode | BFS |
| 121 | Word Ladder II | C++ | _O(n*d)_ | O(d) | Hard | LeetCode | todo |
| 127 | Topological Sorting | C++ | O(V+E) | O(E) | Medium | todo | |
| 137 | Clone Graph | C++ | O(V+E) | O(V) | Medium | BFS | |
| 176 | Route Between Two Nodes in Graph | C++ | O(n) | O(n) | Medium | DFS, BFS | |
| 178 | Graph Valid Tree | C++ | O(V+E) | O(V+E) | Medium | LeetCode | todo |
| 431 | Find the Connected Component in the Undirected Graph | C++ | O(n) | O(n) | Medium | todo | |
| 477 | Surrounded Regions | C++ | _O(m*n)_ | O(m+n) | Medium | LeetCode |
Data Structure
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 134 | LRU Cache | C++ | O(1) | O(k) | Hard | LeetCode, EPI | List, Hash |
Depth-First Search
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 90 | K Sum II | C++ | _O(k*C(n,k))_ | O(k) | Medium | ||
| 376 | Binary Tree Path Sum | C++ | O(n) | O(h) | Easy | LeetCode | |
| 433 | Number of Islands | C++ | _O(m*n)_ | _O(m*n)_ | Easy | LeetCode | DFS |
| 480 | Binary Tree Paths | C++ | _O(n*h)_ | O(h) | Easy | LeetCode |
Dynamic Programming
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 20 | Dices Sum | C++ | O(n^2 ) | O(n) | Hard | todo | |
| 29 | Interleaving String | C++ | _O(m*n)_ | O(min(m,n)) | Medium | EPI | |
| 43 | Maximum Subarray III | C++ | _O(k*n)_ | _O(k*n)_ | Hard | ||
| 77 | Longest Common Subsequence | C++ | _O(m*n)_ | O(min(m,n)) | Medium | ||
| 79 | Longest Common Substring | C++ | _O(m*n)_ | O(min(m,n)) | Medium | ||
| 89 | K Sum | C++ | O(knt) | _O(n*t)_ | Hard | ||
| 91 | Minimum Adjustment Cost | C++ | O(knt) | O(k) | Medium | ||
| 92 | Backpack | C++ | _O(m*n)_ | O(m) | Easy | ||
| 107 | Word Break | C++ | _O(n*l^2 )_ | O(n) | Medium | LeetCode, EPI | todo |
| 108 | Palindrome Partitioning II | C++ | O(n^2 ) | O(n) | Medium | LeetCode, EPI | |
| 109 | Triangle | C++ | O(n) | O(n) | Easy | LeetCode, EPI | |
| 110 | Minimum Path Sum | C++ | _O(m*n)_ | O(min(m,n)) | Easy | LeetCode, EPI | |
| 111 | Climbing Stairs | C++ | O(n) | O(1) | Easy | LeetCode | |
| 115 | Unique Paths II | C++ | _O(m*n)_ | O(min(m,n)) | Easy | LeetCode, CTCI | DP, Math |
| 118 | Distinct Subsequences | C++ | _O(m*n)_ | O(m) | Medium | LeetCode | todo |
| 119 | Edit Distance | C++ | _O(m*n)_ | O(min(m,n)) | Medium | LeetCode, CTCI | DP |
| 125 | Backpack II | C++ | _O(m*n)_ | O(m) | Medium | ||
| 149 | Best Time to Buy and Sell Stock | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 150 | Best Time to Buy and Sell Stock II | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 151 | Best Time to Buy and Sell Stock III | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 154 | Regular Expression Matching | C++ | _O(m*n)_ | O(m) | Hard | LeetCode | todo |
| 168 | Burst Balloons | C++ | O(n^3 ) | O(n^2 ) | Medium | LeetCode | todo |
| 191 | Maximum Product Subarray | C++ | O(n) | O(1) | Medium | LeetCode | |
| 392 | House Robber | C++ | O(n) | O(1) | Medium | LeetCode | |
| 393 | Best Time to Buy and Sell Stock IV | C++ | _O(k*n)_ | O(k) | Hard | LeetCode, EPI | |
| 395 | Coins in a Line II | C++ | O(n) | O(1) | Medium | ||
| 396 | Coins in a Line III | C++ | O(n^2 ) | O(n) | Hard | todo | |
| 397 | Longest Increasing Continuous subsequence | C++ | O(n) | O(1) | Easy | todo | |
| 398 | Longest Increasing Continuous subsequence II | C++ | _O(m*n)_ | _O(m*n)_ | Hard | todo | |
| 403 | Continuous Subarray Sum II | C++ | O(n) | O(1) | Medium | EPI | todo |
| 430 | Scramble String | C++ | O(n^4 ) | O(n^3 ) | Hard | LeetCode | todo |
| 435 | Post Office Problem | C++ | _O(k*n^2 )_ | O(n) | Hard | PKU 1160 | todo |
| 436 | Maximal Square | C++ | _O(m*n)_ | O(n) | Medium | LeetCode | todo |
| 512 | Decode Ways | C++ | O(n) | O(1) | Medium | LeetCode | todo |
| 513 | Perfect Squares | C++ | _O(n*sqrt(n))_ | O(n) | Medium | LeetCode | todo |
| 514 | Paint Fence | C++ | O(n) | O(1) | Easy | LeetCode | todo |
| 515 | Paint House | C++ | O(n) | O(1) | Medium | LeetCode | todo |
| 516 | Paint House II | C++ | _O(n*k)_ | O(k) | Hard | LeetCode | todo |
| 534 | House Robber II | C++ | O(n) | O(1) | Medium | LeetCode | todo |
| 564 | Backpack VI | C++ | _O(n*t)_ | O(t) | Medium |
Greedy
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 41 | Maximum Subarray | C++ | O(n) | O(1) | Easy | LeetCode | |
| 42 | Maximum Subarray II | C++ | O(n) | O(n) | Medium | ||
| 44 | Minimum Subarray | C++ | O(n) | O(1) | Easy | ||
| 45 | Maximum Subarray Difference | C++ | O(n) | O(n) | Medium | ||
| 116 | Jump Game | C++ | O(n) | O(1) | Medium | LeetCode | |
| 117 | Jump Game II | C++ | O(n) | O(1) | Medium | LeetCode | |
| 182 | Delete Digits | C++ | O(n) | O(n) | Medium | ||
| 187 | Gas Station | C++ | O(n) | O(1) | Easy | LeetCode | todo |
| 192 | Wildcard Matching | C++ | O(m+n) | O(1) | Hard | LeetCode | todo |
| 402 | Continuous Subarray Sum | C++ | O(n) | O(1) | Medium | EPI | |
| 412 | Candy | C++ | O(n) | O(n) | Hard | LeetCode | Greedy |
| 552 | Create Maximum Number | C++ | _O(k*(m+n+k))_ ~ _O(k*(m+n+k^2 ))_ | O(m+n+k^2 ) | Hard | LeetCode | todo |
Hash Tables
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 56 | 2 Sum | C++ | O(n) | O(n) | Medium | LeetCode | |
| 124 | Longest Consecutive Sequence | C++ | O(n) | O(n) | Medium | LeetCode, EPI | |
| 128 | Hash Function | C++ | O(n) | O(1) | Easy | ||
| 129 | Rehashing | C++ | O(n) | O(n) | Medium | ||
| 138 | Subarray Sum | C++ | O(n) | O(n) | Easy | ||
| 186 | Max Points on a Line | C++ | O(n^2 ) | O(n) | Medium | LeetCode | |
| 211 | String Permutation | C++ | O(n) | O(1) | Easy | todo | |
| 384 | Longest Substring Without Repeating Characters | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 386 | Longest Substring with At Most K Distinct Characters | C++ | O(n) | O(n) | Medium | todo | |
| 432 | Find the Weak Connected Component in the Directed Graph | C++ | O(nlogn) | O(n) | Medium | todo | |
| 434 | Number of Islands II | C++ | O(k) | O(k) | Hard | todo | |
| 488 | Happy Number | C++ | O(k) | O(k) | Easy | LeetCode | |
| 547 | Intersection of Two Arrays | C++ | O(m+n) | O(min(m,n)) | Easy | EPI, LeetCode | Two Pointers, Binary Search |
| 548 | Intersection of Two Arrays II | C++ | O(m+n) | O(min(m,n)) | Easy | EPI, LeetCode | Two Pointers, Binary Search |
Heap
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 4 | Ugly Number II | C++ | O(n) | O(1) | Medium | CTCI | BST, Heap |
| 81 | Data Stream Median | C++ | O(nlogn) | O(n) | Hard | EPI | BST, Heap |
| 130 | Heapify | C++ | O(n) | O(1) | Medium | ||
| 364 | Trapping Rain Water II | C++ | O(mn(logm+logn)) | _O(m*n)_ | Hard | todo | |
| 518 | Super Ugly Number | C++ | _O(n*k)_ | O(n+k) | Medium | LeetCode | todo |
Linked List
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 16 | Merge Two Sorted Lists | C++ | O(n) | O(1) | Easy | LeetCode, EPI | |
| 35 | Reverse Linked List | C++ | O(n) | O(1) | Easy | LeetCode, EPI | |
| 36 | Reverse Linked List II | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 96 | Partition List | C++ | O(n) | O(1) | Easy | LeetCode | |
| 98 | Sort List | C++ | O(nlogn) | O(logn) | Medium | LeetCode, EPI | todo |
| 99 | Reorder List | C++ | O(n) | O(1) | Medium | LeetCode | |
| 102 | Linked List Cycle | C++ | O(n) | O(1) | Medium | LeetCode | |
| 103 | Linked List Cycle II | C++ | O(n) | O(1) | Hard | LeetCode | todo |
| 104 | Merge k Sorted Lists | C++ | _O(n*logk)_ | _O(1)_ | Medium | LeetCode | Heap, Divide and Conquer |
| 105 | Copy List with Random Pointer | C++ | O(n) | O(1) | Medium | LeetCode | |
| 106 | Convert Sorted List to Binary Search Tree | C++ | O(n) | O(logn) | Medium | LeetCode, EPI | todo |
| 112 | Remove Duplicates from Sorted List | C++ | O(n) | O(1) | Easy | LeetCode, EPI | |
| 113 | Remove Duplicates from Sorted List II | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 166 | Nth to Last Node in List | C++ | O(n) | O(1) | Easy | LeetCode | |
| 167 | Two Lists Sum | C++ | O(n) | O(1) | Easy | LeetCode | todo |
| 170 | Rotate List | C++ | O(n) | O(1) | Medium | LeetCode | |
| 173 | Insertion Sort List | C++ | O(n^2 ) | O(1) | Easy | LeetCode | |
| 174 | Remove Nth Node From End of List | C++ | O(n) | O(1) | Easy | LeetCode | |
| 223 | Palindrome Linked List | C++ | O(n) | O(1) | Medium | LeetCode | |
| 372 | Delete Node in the Middle of Singly Linked List | C++ | O(1) | O(1) | Easy | CTCI | |
| 380 | Intersection of Two Linked Lists | C++ | O(m+n) | O(1) | Easy | LeetCode | |
| 450 | Reverse Nodes in k-Group | C++ | O(n) | O(1) | Hard | LeetCode | |
| 451 | Swap Nodes in Pairs | C++ | O(n) | O(1) | Easy | LeetCode | |
| 452 | Remove Linked List Elements | C++ | O(n) | O(1) | Naive | LeetCode | |
| 511 | Swap Two Nodes in Linked List | C++ | O(n) | O(1) | Medium | todo |
Math
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 2 | Trailing Zeros | C++ | O(1) | O(1) | Easy | LeetCode | |
| 3 | Digit Counts | C++ | O(1) | O(1) | Medium | CTCI | |
| 114 | Unique Paths | C++ | O(min(m,n)) | O(1) | Easy | LeetCode, CTCI | DP, Math |
| 163 | Unique Binary Search Trees | C++ | O(n) | O(1) | Medium | CTCI | DP, Math, Catalan Number |
| 180 | Binary Represention | C++ | O(1) | O(1) | Hard | CTCI | todo |
| 197 | Permutation Index | C++ | O(n^2 ) | O(1) | Easy | ||
| 198 | Permutation Index II | C++ | O(n^2 ) | O(n) | Medium | todo | |
| 394 | Coins in a Line | C++ | O(1) | O(1) | Easy | ||
| 411 | Gray Code | C++ | O(2^n ) | O(1) | Medium | LeetCode | todo |
| 413 | Reverse Integer | C++ | O(1) | O(1) | Medium | LeetCode | |
| 414 | Divide Two Integer | C++ | O(1) | O(1) | Medium | LeetCode | |
| 418 | Integer to Roman | C++ | O(n) | O(1) | Medium | LeetCode | todo |
| 419 | Roman to Integer | C++ | O(n) | O(1) | Medium | LeetCode | todo |
| 428 | Pow(x, n) | C++ | O(1) | O(1) | Medium | LeetCode | |
| 445 | Cosine Similarity | C++ | O(n) | O(1) | Easy | ||
| 517 | Ugly Number | C++ | O(1) | O(1) | Easy | CTCI, LeetCode |
OO Design
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 204 | Singleton | C++ | O(1) | O(1) | Easy | ||
| 208 | Assignment Operator Overloading (C++ Only) | C++ | O(n) | O(1) | Medium | ||
| 496 | Toy Factory | C++ | O(1) | O(1) | Easy | ||
| 497 | Shape Factory | C++ | O(1) | O(1) | Easy | ||
| 498 | Parking Lot | C++ | O(nmk) | O(nmk) | Hard | CTCI | OO Design, Pimpl Idiom, Smart Pointer |
Queue
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 362 | Sliding Window Maximum | C++ | O(n) | O(k) | Hard | EPI | Deque, Tricky |
Recursion
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 22 | Flatten List | C++ | O(n) | O(h) | Easy | ||
| 72 | Construct Binary Tree from Inorder and Postorder Traversal | C++ | O(n) | O(n) | Medium | LeetCode, EPI | |
| 73 | Construct Binary Tree from Preorder and Inorder Traversal | C++ | O(n) | O(n) | Medium | LeetCode, EPI | |
| 93 | Balanced Binary Tree | C++ | O(n) | O(h) | Easy | LeetCode | |
| 94 | Binary Tree Maximum Path Sum | C++ | O(n) | O(h) | Medium | LeetCode | |
| 95 | Validate Binary Search Tree | C++ | O(n) | O(h) | Medium | LeetCode | |
| 97 | Maximum Depth of Binary Tree | C++ | O(n) | O(h) | Easy | LeetCode | |
| 131 | Building Outline | C++ | O(nlogn) | O(n) | Hard | EPI | Sort, BST |
| 140 | Fast Power | C++ | O(logn) | O(1) | Medium | ||
| 155 | Minimum Depth of Binary Tree | C++ | O(n) | O(h) | Easy | LeetCode | |
| 164 | Unique Binary Search Trees II | C++ | _O(n*4^n / n^(3/2) )_ | O(n) | Medium | LeetCode | |
| 177 | Convert Sorted Array to Binary Search Tree With Minimal Height | C++ | O(n) | O(logn) | Easy | LeetCode | |
| 201 | Segment Tree Build | C++ | O(n) | O(h) | Medium | Segment Tree, BST | |
| 202 | Segment Tree Query | C++ | O(h) | O(h) | Medium | Segment Tree, BST | |
| 203 | Segment Tree Modify | C++ | O(h) | O(h) | Medium | Segment Tree, BST | |
| 205 | Interval Minimum Number | C++ | build tree: O(n), query: (h) | O(h) | Hard | Segment Tree, BST | |
| 206 | Interval Sum | C++ | build tree: O(n), query: O(logn) | O(n) | Hard | Segment Tree, BIT | |
| 207 | Interval Sum II | C++ | build tree: O(n), query: O(logn), modify: O(logn) | O(n) | Hard | Segment Tree, BIT | |
| 245 | Subtree | C++ | _O(m*n)_ | O(1) | Easy | Morris Traversal |
|
| 247 | Segment Tree Query II | C++ | O(h) | O(h) | Hard | Segment Tree, BST | |
| 248 | Count of Smaller Number | C++ | build tree: O(n), query: O(logn) | O(h) | Medium | Segment Tree, BST | |
| 371 | Print Numbers by Recursion | C++ | O(n) | O(n) | Medium | ||
| 375 | Clone Binary Tree | C++ | O(n) | O(h) | Easy | ||
| 378 | Convert Binary Search Tree to Doubly Linked List | C++ | O(n) | O(h) | Medium | ||
| 439 | Segment Tree Build II | C++ | O(n) | O(h) | Medium | Segment Tree, BST | |
| 453 | Flatten Binary Tree to Linked List | C++ | O(n) | O(h) | Easy | LeetCode | |
| 469 | Identical Binary Tree | C++ | O(n) | O(h) | Easy | ||
| 532 | Reverse Pairs | C++ | O(nlogn) | O(n) | Medium | variant of Count of Smaller Number before itself | BIT, Merge Sort |
| 535 | House Robber III | C++ | O(n) | O(h) | Medium | LeetCode |
Sort
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 5 | Kth Largest Element | C++ | O(n) ~ O(n^2 ) | O(1) | Medium | EPI | Two Pointers, Quick Sort |
| 80 | Median | C++ | O(n) | O(1) | Easy | EPI | |
| 139 | Subarray Sum Closest | C++ | O(nlogn) | O(n) | Medium | Sort | |
| 143 | Sort Colors II | C++ | O(n) | O(1) | Medium | ||
| 148 | Sort Colors | C++ | O(n) | O(1) | Medium | LeetCode | |
| 156 | Merge Intervals | C++ | O(nlogn) | O(1) | Easy | LeetCode, EPI | |
| 184 | Largest Number | C++ | O(nlogn) | O(1) | Medium | LeetCode | |
| 366 | Fibonacci | C++ | O(n) | O(1) | Easy | ||
| 379 | Reorder array to construct the minimum number | C++ | O(nlogn) | O(1) | Medium | LeetCode | |
| 387 | The Smallest Difference | C++ | O(max(m,n) * log(min(m,n))) | O(1) | Medium | Two Pointers, Binary Search | |
| 399 | Nuts & Bolts Problem | C++ | O(nlogn) | O(logn) | Medium | Quick Sort | |
| 400 | Maximum Gap | C++ | O(n) | O(n) | Hard | LeetCode | Bucket Sort |
| 463 | Sort Integers | C++ | O(n^2 ) | O(1) | Easy | Insertion Sort, Selection Sort, Bubble Sort | |
| 464 | Sort Integers II | C++ | O(nlogn) | O(n) | Easy | Merge Sort, Heap Sort, Quick Sort | |
| 507 | Wiggle Sort II | C++ | O(n) on average | O(1) | Medium | LeetCode | Tri Partition |
| 508 | Wiggle Sort | C++ | O(n) | O(1) | Medium | LeetCode |
Stack
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 12 | Min Stack | C++ | O(n) | O(1) | Medium | LeetCode, EPI | |
| 40 | Implement Queue by Two Stacks | C++ | O(1), amortized | O(n) | Medium | EPI | |
| 66 | Binary Tree Preorder Traversal | C++ | O(n) | O(1) | Easy | LeetCode, EPI | Morris Traversal |
| 67 | Binary Tree Inorder Traversal | C++ | O(n) | O(1) | Easy | LeetCode, EPI | Morris Traversal |
| 68 | Binary Tree Postorder Traversal | C++ | O(n) | O(1) | Easy | LeetCode, EPI | Morris Traversal |
| 122 | Largest Rectangle in Histogram | C++ | O(n) | O(n) | Hard | LeetCode, EPI | Ascending Stack |
| 126 | Max Tree | C++ | O(n) | O(n) | Hard | Descending Stack | |
| 367 | Expression Tree Build | C++ | O(n) | O(n) | Hard | ||
| 368 | Expression Evaluation | C++ | O(n) | O(n) | Hard | ||
| 369 | Convert Expression to Polish Notation | C++ | O(n) | O(n) | Hard | ||
| 370 | Convert Expression to Reverse Polish Notation | C++ | O(n) | O(n) | Hard | ||
| 421 | Simplify Path | C++ | O(n) | O(n) | Medium | LeetCode | |
| 423 | Valid Parentheses | C++ | O(n) | O(n) | Easy | LeetCode | |
| 424 | Evaluate Reverse Polish Notation | C++ | O(n) | O(n) | Medium | LeetCode | |
| 473 | Add and Search Word | C++ | O(min(n,h)) | O(min(n,h) | Medium | LeetCode | Trie |
| 510 | Maximal Rectangle | C++ | _O(m*n)_ | O(n) | Hard | LeetCode | Ascending Stack |
| 528 | Flatten Nested List Iterator | C++ | O(n) | O(h) | Medium | LeetCode |
String
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 13 | strStr | C++ | O(n+k) | O(k) | Easy | LeetCode | KMP Algorithm |
| 53 | Reverse Words in a String | C++ | O(n) | O(1) | Easy | LeetCode, EPI | |
| 54 | String to Integer(atoi) | C++ | O(n) | O(1) | Hard | LeetCode | |
| 55 | Compare Strings | C++ | O(n) | O(c) | Easy | ||
| 78 | Longest Common Prefix | C++ | O(n) | O(1) | Medium | ||
| 157 | Unique Characters | C++ | O(n) | O(1) | Easy | CTCI | |
| 158 | Two Strings Are Anagrams | C++ | O(n) | O(1) | Easy | ||
| 171 | Anagrams | C++ | _O(n*klogk)_ | O(m) | Easy | LeetCode, EPI | |
| 212 | Space Replacement | C++ | O(n) | O(1) | Easy | ||
| 407 | Plus One | C++ | O(n) | O(1) | Easy | LeetCode | |
| 408 | Add Binary | C++ | O(n) | O(1) | Easy | LeetCode | |
| 415 | Valid Palindrome | C++ | O(n) | O(1) | Easy | LeetCode | |
| 417 | Valid Number | C++ | O(n) | O(1) | Hard | LeetCode | Automata |
| 420 | Count and Say | C++ | _O(n*2^n )_ | O(2^n ) | Easy | LeetCode | |
| 422 | Length of Last Word | C++ | O(n) | O(1) | Easy | LeetCode | |
| 524 | Left Pad | C++ | O(p+n) | O(1) | Easy | LeetCode |
System Design
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 501 | Mini Twitter | C++ | O(klogu) | O(t+f) | Medium |
Tree
| PID# | Title | Source | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 7 | Binary Tree Serialization | C++ | O(n) | O(h) | Medium | ||
| 85 | Insert Node in a Binary Search Tree | C++ | O(h) | O(1) | Easy | ||
| 88 | Lowest Common Ancestor | C++ | O(n) | O(h) | Medium | EPI | |
| 175 | Invert Binary Tree | C++ | O(n) | O(h) | Easy | LeetCode | |
| 442 | Implement Trie | C++ | O(n) | O(1) | Medium | LeetCode | Trie |
[LintCode]——目录的更多相关文章
- UWP学习目录整理
UWP学习目录整理 0x00 可以忽略的废话 10月6号靠着半听半猜和文字直播的补充看完了微软的秋季新品发布会,信仰充值成功,对UWP的开发十分感兴趣,打算后面找时间学习一下.谁想到学习的欲望越来越强 ...
- 基于DDD的现代ASP.NET开发框架--ABP系列文章总目录
ABP相关岗位招聘:给热爱.NET新技术和ABP框架的朋友带来一个高薪的工作机会 ABP交流会录像视频:ABP架构设计交流群-7月18日上海线下交流会的内容分享(有高清录像视频的链接) 代码自动生成: ...
- ABP教程-打造一个《电话簿项目》-目录-MPA版本-基于ABP1.13版本
此系列文章会进行不定期的更新,应该会有6章左右. 感兴趣的朋友可以跟着看看,本教程适合已经看过ABP的文档但是又无从下手的小伙伴们. 初衷: 发布系列教程的原因是发现ABP在园子火了很久,但是发现还是 ...
- ABP源码分析一:整体项目结构及目录
ABP是一套非常优秀的web应用程序架构,适合用来搭建集中式架构的web应用程序. 整个Abp的Infrastructure是以Abp这个package为核心模块(core)+15个模块(module ...
- SQLServer执行命令出现“目录无效的提示”
异常处理汇总-数据库系列 http://www.cnblogs.com/dunitian/p/4522990.html 一般都是清理垃圾清理过头了,把不该删的目录删了 网上说法: 问题描述: 1.s ...
- [APUE]文件和目录(下)
一.mkdir和rmdir函数 #include <sys/types.h> #include <sys/stat.h> int mkdir(const char *pathn ...
- [APUE]文件和目录(中)
一.link.unlink.remove和rename 一个文件可以有多个目录项指向其i节点.使用link函数可以创建一个指向现存文件连接 #include <unistd.h> int ...
- [APUE]文件和目录(上)
一.文件权限 1. 各种ID 我在读这一章时遇到了各种ID,根据名字完全不清楚什么意思,幸好看到了这篇文章,http://blog.csdn.net/ccjjnn19890720/article/de ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(1)-前言与目录(持续更新中...)
开发工具:VS2015(2012以上)+SQL2008R2以上数据库 您可以有偿获取一份最新源码联系QQ:729994997 价格 666RMB 升级后界面效果如下: 任务调度系统界面 http: ...
随机推荐
- In-Memory:内存数据库
在逝去的2016后半年,由于项目需要支持数据的快速更新和多用户的高并发负载,我试水SQL Server 2016的In-Memory OLTP,创建内存数据库实现项目的负载需求,现在项目接近尾声,系统 ...
- java基础集合经典训练题
第一题:要求产生10个随机的字符串,每一个字符串互相不重复,每一个字符串中组成的字符(a-zA-Z0-9)也不相同,每个字符串长度为10; 分析:*1.看到这个题目,或许你脑海中会想到很多方法,比如判 ...
- Oracle分析函数入门
一.Oracle分析函数入门 分析函数是什么?分析函数是Oracle专门用于解决复杂报表统计需求的功能强大的函数,它可以在数据中进行分组然后计算基于组的某种统计值,并且每一组的每一行都可以返回一个统计 ...
- CSS十问——好奇心+刨根问底=CSSer
最近有时间,想把酝酿的几篇博客都写出来,今天前端小学生带着10个问题,跟大家分享一下学习CSS的一些体会,我觉得想学好CSS,必须保持一颗好奇心和刨根问底的劲头,而不是复制粘贴,得过且过.本人能力有限 ...
- Modify Branding of FreeCAD
Modify Branding of FreeCAD eryar@163.com This article describes the Branding of FreeCAD. Branding me ...
- 深入.NET平台和C#编程总结大全
对于初学者的你,等到你把这个看完之后就更清楚地认知.NET和C#编程了,好了废话不多说,开始吧! ...
- 手机web如何实现多平台分享
话说App一般都带有分享到社交平台的入口,web网页的分享也有很不错的框架,但是随着HTML5的不断发展,手机web页面越来越多的进入到我们的生活中,那如何在我们的手机上完成分享呢?话说各大分享平台都 ...
- Android中的LinearLayout布局
LinearLayout : 线性布局 在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了, 线性布局是按照垂直方向(vertical)或水平方向 ...
- Android Weekly Notes Issue #236
Android Weekly Issue #236 December 18th, 2016 Android Weekly Issue #236 本期内容包括: Google的物联网平台Android ...
- 从零开始,DIY一个jQuery(3)
在前两章,为了方便调试,我们写了一个非常简单的 jQuery.fn.init 方法: jQuery.fn.init = function (selector, context, root) { if ...