Skip to content

RideGreg/LintCode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Up to date (2016-08-22), there are 289 problems on LintCode Online Judge. The number of problems is increasing recently. Here is the classification of all 289 problems. For more problems and solutions, you can see my LeetCode repository. I'll keep updating for full summary and better solutions. Stay tuned for updates.

[1-50] [51-100] [101-150] [151-200] [201-250] [251-300]
[301-350] [351-400] [401-450] [451-500] [501-550] [551-600]
[601-650] [651-700] [701-750] [751-800] [801-850] [851-900]
[901-950] [951-1000] [1001-1050] [1051-1100] [1101-1150] [1151-1200]
[1201-1250] [1251-1300] [1301-1350] [1351-1400] [1401-1450] [1451-1500]
[1501-1550] [1551-1600] [1601-1650] [1651-1700] [1701-1750] [1751-1800]
[1801-1850] [1851-1900] [1901-1950] [1951-2000] [2001-2050] [2051-2100]

Algorithms

Bit Manipulation

# Title Solution 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++ Python 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

Array

# Title Solution Time Space Difficulty Tag Note
6 Merge Sorted Array Python C++ Java O(m + n) O(1) Easy LeetCode Two Pointers
8 Rotate String C++ O(n) O(1) Easy LeetCode
9 Fizz Buzz C++ O(n) O(1) Easy
30 Insert Interval C++ Python O(n) O(1) Easy LeetCode, EPI, Google Ladder 18/7
31 Partition Array C++ O(n) O(1) Medium Two Pointers
32 Minimum Window Substring C++ O(n) O(1) Medium LeetCode
38 Search a 2D Matrix II C++ O(m + n) O(1) Medium EPI
39 Recover Rotated Sorted Array C++ O(n) O(1) Easy
46 Majority Number C++ O(n) O(1) Easy LeetCode
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 Hash
59 3 Sum Closest C++ O(n^2) O(1) Medium LeetCode Two Pointers, Sort
64 Merge Sorted Array II Python C++ O(m + n) O(1) Easy LeetCode Two Pointers
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
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
382 Triangle Count C++ O(n^2) O(1) Medium Two Pointers
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 Uber,Snapchat,Apple,LeetCode 036
402 Continuous Subarray Sum Python O(n) O(1) Easy Facebook
404 Subarray Sum II C++ O(nlogn) O(n) Hard Two Pointers, Binary Search
405 Submatrix Sum C++ O(m * n^2) O(m) Hard Hash
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
601 Flatten 2D Vector O(1) O(1) Medium Airbnb,Twitter,Google,LeetCode 251
817 Range Sum Query 2D - Mutable Python O(logMlogN) O(M*N) Hard Google Ladder 18/7 Bit Indexed Tree, TLE Segment Tree
840 Range Sum Query - Mutable Python O(logn) O(n) Medium Segment Tree
943 Range Sum Query - Immutable Python O(1) O(n) Easy prefixSum
1391 Making A Large Island O(n^2) O(n^2) Hard Uber,LeetCode 827 2D Union Find
1539 Flipped The Pixel Python O(m*n) O(1) Easy Google Ladder 18/6
1555 Flower Problem Python O(n) O(n) Hard Google Ladder 18/6 Union Find
1628 Driving Problem Python O(n*n) O(n) Hard Google Ladder 18/8 2D Union Find
1631 Interesting Subarray Python O(n) O(n) Medium Google Ladder 18/8 Two Pointers
1641 Max Remove Order Python O(mn) O(mn) Hard Google Ladder 18/9 Union Find
1643 Pick Fruits Python O(n) O(n) Medium Google Ladder 18/9 Two Pointers
1644 Plane Maximum Rectangle Python O(n^2) O(n) Medium Google Ladder 18/9

String

# Title Solution 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 Uber,LeetCode 8
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 Uber, LeetCode 125
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
633 Find the Duplicate Number Python O(n) O(1) Hard Google Ladder 18/7 fast-slow-pointers
640 One Edit Distance Medium Uber, LeetCode 161
927 Reverse Words in a String ii Medium Uber, LeetCode 186

|1086|Repeated String Match|Python| O(n*(m+n)) | O(m+n) | Easy | Google Ladder 18/6, LeetCode | | |1540|Can Convert|Python| O(min(s, t)) | O(1) | Easy | Google Ladder 18/6 | Two Pointers | |1542|Nexttime Norepeat|Python| O(1)) | O(1) | Easy | Google Ladder 18/6 | | |1545|Last Closest Time|Python| O(1)) | O(1) | Easy | Google Ladder 18/6 | | |1554|Lasttime Norepeat|Python| O(1)) | O(1) | Easy | Google Ladder 18/6 | | |1580|Transition String|Python| O(n)) | O(n) | Medium | Google Ladder 18/7 | | |1625|Words Compression|Python| O(n+k)) | O(k) | Hard | Google Ladder 18/8 | KMP Algorithm | |1627|Word Segmentation|Python| O(n)) | O(1) | Easy | Google Ladder 18/8 | | |1632|Count Email Groups|Python| O(n)) | O(n) | Easy | Google Ladder 18/8 | | |1634|Secret Word|Python| O((n-w)*w)) | O(w) | Easy | Google Ladder 18/9 | | |1642|Query String|Python| O(n)) | O(1) | Hard | Google Ladder 18/9 | Suffix Tree? |

Linked List

# Title Solution 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 Uber,LeetCode 206, 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
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
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
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
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++ Python O(n) O(1) Medium Uber,Microsoft,Bloomberg,LeetCode 024
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

Tree

# Title Solution Time Space Difficulty Tag Note
7 Binary Tree Serialization C++ O(n) O(h) Medium Uber,LeetCode 297
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
1577 Sum of Leaf Nodes Python O(n) O(1) Hard Google Ladder 18/7 Morris
1624 Max Distance Python O(n*l) O(n*l) Hard Google Ladder 18/8 Trie

Stack

# Title Solution Time Space Difficulty Tag Note
12 Min Stack C++ O(n) O(1) Medium Uber,LeetCode 155, 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++ Python O(n) O(n) Easy Uber,Airbnb,Google,Facebook,Amazon,Twitter,LeetCode 020
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
1001 Asteroid Collision O(n) O(n) Medium Uber, LeetCode 735

Queue

# Title Solution Time Space Difficulty Tag Note
362 Sliding Window Maximum C++ O(n) O(k) Hard EPI Deque, Tricky

Heap

# Title Solution 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(m * n * (logm + logn)) O(m * n) Hard BFS, Heap, Tricky
471 Top K Frequent Words Medium Uber, LeetCode 692 Heap, Bucket Sort
518 Super Ugly Number C++ O(n * k) O(n + k) Medium LeetCode BST, Heap
1571 Top K GPA Python O(n * logk) O(k) Medium Google Ladder 18/7 Heap

Hash Tables

# Title Solution Time Space Difficulty Tag Note
56 2 Sum C++ O(n) O(n) Medium Uber,LeetCode 001
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
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
432 Find the Weak Connected Component in the Directed Graph C++ O(nlogn) O(n) Medium Union Find
434 Number of Islands II C++ O(k) O(k) Hard Union Find
488 Happy Number C++ Python O(k) O(k) Easy Uber, Airbnb, Twitter,LeetCode 202
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
828 Word Pattern Python O(n) O(c), c is number of unique patterns Easy Uber, Dropbox Leetcode 290
829 Word Pattern II O(n * C(n-1, c-1)) O(n+c) Hard Uber, Dropbox Leetcode 291,10,44
1443 longest-ab-substring Python O(n) O(n) Medium prefixSum, Hash Table

Data Structure

# Title Solution Time Space Difficulty Tag Note
134 LRU Cache C++ O(1) O(k) Hard LeetCode, EPI List, Hash
1245 All O`one Data Structure O(1) O(k) Hard Uber, LeetCode 432 Double Linked List, Hash

Math

# Title Solution 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
147 Narcissistic Number Python O(10^n*n) Easy CAT Brute Force
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
197 Permutation Index C++ O(n^2) O(1) Easy
198 Permutation Index II C++ O(n^2) O(n) Medium
394 Coins in a Line C++ O(1) O(1) Easy
411 Gray Code C++ O(2^n) O(1) Medium LeetCode
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
419 Roman to Integer C++ O(n) O(1) Medium LeetCode
428 Pow(x, n) C++ O(1) O(1) Medium LeetCode
445 Cosine Similarity C++ Python O(n) O(1) Easy
517 Ugly Number C++ O(1) O(1) Easy CTCI, LeetCode
1544 Magic Square Python O(n*n) O(n*n) Hard Google Ladder 18/6

Sort

# Title Solution 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++ Python 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
1465 Order Of Tasks Python O(n) O(1) Medium Greedy

Recursion

# Title Solution 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++ Python O(n) O(h) Easy LeetCode Tree DP
94 Binary Tree Maximum Path Sum C++ Python O(n) O(h) Medium LeetCode Tree DP
95 Validate Binary Search Tree C++ O(n) O(h) Medium LeetCode
97 Maximum Depth of Binary Tree C++ O(n) O(h) Easy Uber,LinkedIn,LeetCode 104
131 Building Outline C++ Python 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
XXX Topological Sort Python O(V+E) O(h) Medium Topological Sort

Binary Search

# Title Solution 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 Uber,LeetCode 4, EPI Tricky
74 First Bad Version C++ O(logn) O(1) Medium
75 Find Peak Element C++ Python O(logn) O(1) Medium LeetCode
76 Longest Increasing Subsequence C++ Python O(nlogn) O(n) Medium CTCI, Leetcode 300
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 Python O(m + n) O(1) Hard
437 Copy Books C++ O(nlogp) O(1) Hard UVa 714
458 Last Position of Target Python O(logn) O(1) Easy Google Ladder 18/7
1077 Falling Squares O(nlogn) O(n) Hard Uber, LeetCode 699 Segment Tree
1564 Interval Search Python O(logn) O(1) Easy Google Ladder 18/7
1623 Minimal Distance in the Array Python O(min(MlogN, NlogN)) O(1) Google Ladder 18/8
1626 Salary Adjustment Python O(log(target/n)) O(1) Easy Google Ladder 18/8
1633 Strings that Satisfies the Condition Python O(n*len(s)) O(1) Easy Google Ladder 18/9
1629 Find the Nearest Store Python O(min(HlogS, SlogS)) O(1) Easy Google Ladder 18/8
1645 Least Subsequences Python O(nlogn) O(n) Medium Google Ladder 18/9

Breadth-First Search

# Title Solution Time Space Difficulty Tag Note
69 Binary Tree Level Order Traversal C++ O(n) O(n) Medium Uber, LeetCode 102 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 BFS, Back Trace
127 Topological Sorting C++ O(|V|+|E|) O(|E|) Medium DFS, BFS
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
431 Find the Connected Component in the Undirected Graph C++ O(n) O(n) Medium BFS
477 Surrounded Regions C++ O(m * n) O(m + n) Medium LeetCode
630 Knight Shortest Path II Python O(m * n) O(m * n) Easy BFS or DP
825 Bus Station Python O(#of stops) O(#of stops) Hard Google Ladder 18/6

Depth-First Search

# Title Solution 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
795 4-Way Unique Pathsp Python O(m*n) O(m*n) Medium
1630 Interesting String Python O(n) Medium Google Ladder 18/8
1646 CheckWords Python O(n) Easy Google Ladder 18/9 DFS + Memorization

Backtracking

# Title Solution 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 Uber,LeetCode 78
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(m * n * l) O(l) Medium LeetCode
132 Word Search II C++ O(m * n * l) 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^(1/2)) O(n) Medium Uber,LeetCode 022
802 Sudoku Solver O((9!)^9) O(1) Hard Uber, LeetCode 37
1576 Optimal Match Python ?? O(n) Hard Google Ladder 18/9 Hungary Algorithm

Binary Search Trees

# Title Solution 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
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 BST, Tricky
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
902 Kth Smallest Element in a BST Python O(k) O(k) Easy Google Ladder 18/7,Uber LeetCode 230 BST

Dynamic Programming

# Title Solution Time Space Difficulty Tag Note
20 Dices Sum C++ O(n^2) O(n) Hard
29 Interleaving String Python C++ O(m * n) O(min(m, n)) Medium LeetCode 97, 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(k * n * t) O(n * t) Hard
91 Minimum Adjustment Cost C++ O(k * n * t) O(k) Medium
92 Backpack C++ Python O(m * n) O(m) Easy
107 Word Break C++ O(n * l^2) O(n) Medium LeetCode, EPI
108 Palindrome Partitioning II C++ O(n^2) O(n) Medium LeetCode, EPI
109 Triangle C++ Python 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 DP
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 Uber,Airbnb,LeetCode 10 DP, Recursion
168 Burst Balloons C++ O(n^3) O(n^2) Medium LeetCode
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
397 Longest Increasing Continuous subsequence C++ O(n) O(1) Easy
398 Longest Increasing Continuous subsequence II C++ O(m * n) O(m * n) Hard
403 Continuous Subarray Sum II C++ O(n) O(1) Medium EPI
430 Scramble String C++ O(n^4) O(n^3) Hard LeetCode
435 Post Office Problem C++ O(k * n^2) O(n) Hard PKU 1160
436 Maximal Square C++ O(m * n) O(n) Medium LeetCode
512 Decode Ways C++ O(n) O(1) Medium LeetCode
513 Perfect Squares C++ O(n * sqrt(n)) O(n) Medium LeetCode
514 Paint Fence C++ O(n) O(1) Easy LeetCode
515 Paint House C++ O(n) O(1) Medium LeetCode
516 Paint House II C++ O(n * k) O(k) Hard LeetCode
534 House Robber II C++ O(n) O(1) Medium LeetCode
564 Backpack VI C++ O(n * t) O(t) Medium
630 Knight Shortest Path II Python O(m * n) O(m * n) Easy
631 Maximal Square II Python O(m * n) O(n) Easy Amazon
741 Calculate Maximum Value II Python O(n^2) O(n^2) Easy Interval DP
843 Digital Flip Python O(n) O(1) Medium Microsoft
953 The Biggest Score On The Tree Python O(n) O(h) Medium Airbnb Tree DP
1224 Count The Repetitions Python O(n1 * len(s1)) O(n1) Super Hard
1383 Subtree Count Python O(n) O(n) Medium
1384 Segment Stones Merge Python C++ Java O(n^3) O(n^3) Super Hard 3d DP
1395 The Barycentre Of The Trees Python O(n) O(n) Hard Facebook Tree DP
1400 Fermat Point Of Graphs Python O(n) O(n) Super Hard Google Tree DP
1414 Eat The Beans Python C++ O(w*r) O(w*r) Medium Twitter
1444 Dyeing Problem Python O(n) O(1) Medium Alibaba
1447 Calculation the Sum of Path Python C++ Java O(l * w) O(l * w) Medium Google
1448 Card Game Python C++ Java O(n * totalProfit * totalCost) O(totalProfit * totalCost) Medium Google
1470 The Game Of Take Numbers Python O(n*n) O(n) Medium Google Ladder 18/7 Interval
1538 Card Game II Python O(n * totalMoney) O(totalMoney) Easy Google Ladder 18/6 backpack
1541 Put Box Python O(m*n) O(m*n) Medium Google Ladder 18/6 Interval
1543 Unique Path IV Python O(h*w) O(h) Medium Google Ladder 18/6 Coordinate
1621 Cut Connection Python O(m*n) O(1) Medium Google Ladder 18/8 Coordinate
1640 Duplicate Digits Python O(1) Hard Google Ladder 18/9

Greedy

# Title Solution 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
192 Wildcard Matching C++ O(m + n) O(1) Hard LeetCode Greedy, DP, Recursion
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 Greedy, DP

OO Design

# Title Solution Time Space Difficulty Tag Note
204 Singleton C++ Python O(1) O(1) Easy
208 Assignment Operator Overloading (C++ Only) C++ O(n) O(1) Medium
496 Toy Factory C++ Python O(1) O(1) Easy
497 Shape Factory C++ Python O(1) O(1) Easy
498 Parking Lot C++ Python Java O(n * m * k) O(n * m * k) Hard CTCI OO Design
708 Elevator System OO Design Python C++ Java Hard OO Design
709 Restaurant OO Design C++ Java Hard OO Design
710 Hotel OO Design C++ Java Hard OO Design
712 Vending Machine OO Design C++ Java Medium OO Design
714 Black Jack OO Design C++ Java Medium OO Design
731 Restaurant II OO Design C++ Java Hard OO Design
732 Hotel II OO Design C++ Java Hard OO Design
746 Tic Tac Toe OO Design C++ Java Python Hard OO Design
747 Coffee Maker OO Design C++ Java Medium OO Design, decorator
748 Kindle OO Design C++ Java Easy OO Design, factory

System Design

# Title Solution Time Space Difficulty Tag Note
Sys1 News Feed System
501 Mini Twitter C++ Python O(klogu) O(t + f) Medium Heap
560 Friendship Service Python Easy Hash
Sys2 Database and Cache
519 Consistent Hashing Python O(nlogn) O(n) Easy Heap
520 Consistent Hashing II Python Medium bisect, random
538 Memcache Python Easy Hash
502 mini-cassandra Python Easy Hash
134 LRU Cache Python O(1) O(k) Hard Uber,LeetCode 146 OrderedDict, Doubly LinkedList + Hash
24 LFU Cache Python O(1) O(k) Hard Doubly LinkedList + Hash
Sys3 Tiny URL
232 Tiny Url Python Easy Hash, Dict
522 Tiny Url II Python Medium Hash, Dict
526 Load Balancer Python Easy Set, random
Sys4 Location Based Service
529 Geohash Python Medium Geohash
530 Geohash II Python Medium Geohash
525 Mini Uber Python Medium
509 Mini Yelp Python Hard Geohash, Bisect
Sys5 Web Crawler and Google Suggestion
500 Inverted Index Python Easy
523 Url Parser Python Hard Regex
442 Implement Trie (Prefix Tree) Python Medium Trie
559 Trie Service Python Medium Trie
527 Trie Serializatioin Python Hard Trie, Stack
231 Typeahead Python Medium Set
234 Webpage Crawler Python Hard Thread
Sys6 Distributed File System
566 GFS Client Python Easy
565 Heart Beat Python Easy
Sys7 Map Reduce
499 Word Count (Map Reduce) Python Easy
549 Top K Frequent Words (Map Reduce) C++ Medium
503 Anagram (Map Reduce) Python Easy
504 Inverted Index (Map Reduce) Python Easy
654 Sparse Matrix Multiplication Python Easy
Sys8 Bigtable
556 Standard Bloom Filter Python Medium Hash
555 Counting Bloom Filter Python Medium Hash
486 Merge K Sorted Arrays Python Easy Heap
Sys9 Message System, Rate Limiter and Design Pattern
505 Web logger Python Easy
215 Rate Limiter Python Hard Bisect

About

✏️ C++ 11 Solutions of All 289 LintCode Problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 48.0%
  • C++ 45.3%
  • Java 6.7%