| 1 |
Easy |
Two Sum |
1-two-sum.cpp |
O(n) |
O(n) |
| 2 |
Medium |
Add Two Numbers |
2-add-two-numbers.cpp |
O(n1+n2) |
O(n1+n2) |
| 3 |
Medium |
Longest Substring Without Repeating Characters |
3-longest-substring-without-repeating-characters.cpp |
O(n) |
O(n) |
| 5 |
Medium |
Longest Palindromic Substring |
5-longest-palindromic-substring.cpp |
O(n^2) |
O(n) |
| 6 |
Medium |
Zigzag Conversion |
6-zigzag-conversion.cpp |
O(n) |
O(n) |
| 8 |
Medium |
String to Integer (atoi) |
8-string-to-integer-atoi.cpp |
O(n) |
O(1) |
| 9 |
Easy |
Palindrome Number |
9-palindrome-number.cpp |
O(1) |
O(1) |
| 19 |
Medium |
Remove Nth Node From End of List |
19-remove-nth-node-from-end-of-list.cpp |
O(n) |
O(1) |
| 20 |
Easy |
Valid Parentheses |
20-valid-parentheses.cpp |
O(n) |
O(n) |
| 21 |
Easy |
Merge Two Sorted Lists |
21-merge-two-sorted-lists.cpp |
O(min(n1, n2)) |
O(1) |
| 22 |
Medium |
Generate Parentheses |
22-generate-parentheses.cpp |
O(C(n)), where C(n) = the n-th Catalan number |
O(C(n)), where C(n) = the n-th Catalan number |
| 23 |
Hard |
Merge k Sorted Lists |
23-merge-k-sorted-lists.cpp |
O(n*log(k)) |
O(k) |
| 28 |
Easy |
Find the Index of the First Occurrence in a String |
28-find-the-index-of-the-first-occurrence-in-a-string.cpp |
O(m+n) |
O(m) |
| 31 |
Medium |
Next Permutation |
31-next-permutation.cpp |
O(n) |
O(1) |
| 33 |
Medium |
Search in Rotated Sorted Array |
33-search-in-rotated-sorted-array.cpp |
O(log(n)) |
O(log(n)) |
| 35 |
Easy |
Search Insert Position |
35-search-insert-position.cpp |
O(log(n)) |
O(1) |
| 39 |
Medium |
Combination Sum |
39-combination-sum.cpp |
O(2^(n+t)*t) |
O(2^(n+t)*t) |
| 46 |
Medium |
Permutations |
46-permutations.cpp |
O(n*n!) |
O(n*n!) |
| 48 |
Medium |
Rotate Image |
48-rotate-image.cpp |
O(n^2) |
O(1) |
| 49 |
Medium |
Group Anagrams |
49-group-anagrams.cpp |
O(n*m*log(m)) |
O(n*m) |
| 50 |
Medium |
Pow(x, n) |
50-powx-n.cpp |
O(log(n)) |
O(log(n)) |
| 53 |
Medium |
Maximum Subarray |
53-maximum-subarray.cpp |
O(n) |
O(1) |
| 55 |
Medium |
Jump Game |
55-jump-game.cpp |
O(n) |
O(1) |
| 62 |
Medium |
Unique Paths |
62-unique-paths.cpp |
O(m*n) |
O(m*n) |
| 63 |
Medium |
Unique Paths II |
63-unique-paths-ii.cpp |
O(m*n) |
O(m*n) |
| 64 |
Medium |
Minimum Path Sum |
64-minimum-path-sum.cpp |
O(m*n) |
O(m*n) |
| 70 |
Easy |
Climbing Stairs |
70-climbing-stairs.cpp |
O(n) |
O(n) |
| 75 |
Medium |
Sort Colors |
75-sort-colors.cpp |
O(n) |
O(1) |
| 76 |
Hard |
Minimum Window Substring |
76-minimum-window-substring.cpp |
O(m+n) |
O(m) |
| 77 |
Medium |
Combinations |
77-combinations.cpp |
O(k*C(n,k)) |
O(k*C(n,k)) |
| 78 |
Medium |
Subsets |
78-subsets.cpp |
O(n*2^n) |
O(n*2^n) |
| 82 |
Medium |
Remove Duplicates from Sorted List II |
82-remove-duplicates-from-sorted-list-ii.cpp |
O(n) |
O(1) |
| 83 |
Easy |
Remove Duplicates from Sorted List |
83-remove-duplicates-from-sorted-list.cpp |
O(n) |
O(1) |
| 88 |
Easy |
Merge Sorted Array |
88-merge-sorted-array.cpp |
O(m+n) |
O(1) |
| 91 |
Medium |
Decode Ways |
91-decode-ways.cpp |
O(n) |
O(n) |
| 94 |
Easy |
Binary Tree Inorder Traversal |
94-binary-tree-inorder-traversal.cpp |
O(n) |
O(n) |
| 95 |
Medium |
Unique Binary Search Trees II |
95-unique-binary-search-trees-ii.cpp |
O(C(n)), where C(n) = the n-th Catalan number |
O(C(n)) |
| 98 |
Medium |
Validate Binary Search Tree |
98-validate-binary-search-tree.cpp |
O(n) |
O(log(n)) |
| 102 |
Medium |
Binary Tree Level Order Traversal |
102-binary-tree-level-order-traversal.cpp |
O(n) |
O(n) |
| 103 |
Medium |
Binary Tree Zigzag Level Order Traversal |
103-binary-tree-zigzag-level-order-traversal.cpp |
O(n) |
O(n) |
| 104 |
Easy |
Maximum Depth of Binary Tree |
104-maximum-depth-of-binary-tree.cpp |
O(n) |
O(log(n)) |
| 105 |
Medium |
Construct Binary Tree from Preorder and Inorder Traversal |
105-construct-binary-tree-from-preorder-and-inorder-traversal.cpp |
O(n) |
O(n) |
| 108 |
Easy |
Convert Sorted Array to Binary Search Tree |
108-convert-sorted-array-to-binary-search-tree.cpp |
O(n) |
O(n) |
| 111 |
Easy |
Minimum Depth of Binary Tree |
111-minimum-depth-of-binary-tree.cpp |
O(n) |
O(log(n)) |
| 112 |
Easy |
Path Sum |
112-path-sum.cpp |
O(n) |
O(n) |
| 113 |
Medium |
Path Sum II |
113-path-sum-ii.cpp |
O(n^2) |
O(n^2) |
| 116 |
Medium |
Populating Next Right Pointers in Each Node |
116-populating-next-right-pointers-in-each-node.cpp |
O(n) |
O(1) |
| 118 |
Easy |
Pascal's Triangle |
118-pascals-triangle.cpp |
O(n^2) |
O(n^2) |
| 120 |
Medium |
Triangle |
120-triangle.cpp |
O(n^2) |
O(n^2) |
| 121 |
Easy |
Best Time to Buy and Sell Stock |
121-best-time-to-buy-and-sell-stock.cpp |
O(n) |
O(1) |
| 122 |
Medium |
Best Time to Buy and Sell Stock II |
122-best-time-to-buy-and-sell-stock-ii.cpp |
O(n) |
O(1) |
| 124 |
Hard |
Binary Tree Maximum Path Sum |
124-binary-tree-maximum-path-sum.cpp |
O(n) |
O(n) |
| 127 |
Hard |
Word Ladder |
127-word-ladder.cpp |
O(m*n^2) |
O(m*n) |
| 136 |
Easy |
Single Number |
136-single-number.cpp |
O(n) |
O(1) |
| 139 |
Medium |
Word Break |
139-word-break.cpp |
O(m*n) |
O(n) |
| 141 |
Easy |
Linked List Cycle |
141-linked-list-cycle.cpp |
O(n) |
O(1) |
| 142 |
Medium |
Linked List Cycle II |
142-linked-list-cycle-ii.cpp |
O(n) |
O(1) |
| 144 |
Easy |
Binary Tree Preorder Traversal |
144-binary-tree-preorder-traversal.cpp |
O(n) |
O(n) |
| 145 |
Easy |
Binary Tree Postorder Traversal |
145-binary-tree-postorder-traversal.cpp |
O(n) |
O(n) |
| 146 |
Medium |
LRU Cache |
146-lru-cache.cpp |
O(1) for { get(key), put(key, value) } |
O(n) |
| 153 |
Medium |
Find Minimum in Rotated Sorted Array |
153-find-minimum-in-rotated-sorted-array.cpp |
O(log(n)) |
O(log(n)) |
| 155 |
Medium |
Min Stack |
155-min-stack.cpp |
O(1) for { push(x), pop(), top(), getMin() } |
O(n) |
| 165 |
Medium |
Compare Version Numbers |
165-compare-version-numbers.cpp |
O(n1+n2) |
O(1) |
| 167 |
Medium |
Two Sum II - Input Array Is Sorted |
167-two-sum-ii-input-array-is-sorted.cpp |
O(n) |
O(1) |
| 174 |
Hard |
Dungeon Game |
174-dungeon-game.cpp |
O(m*n) |
O(m*n) |
| 189 |
Medium |
Rotate Array |
189-rotate-array.cpp |
O(n) |
O(1) |
| 190 |
Easy |
Reverse Bits |
190-reverse-bits.cpp |
O(1) |
O(1) |
| 191 |
Easy |
Number of 1 Bits |
191-number-of-1-bits.cpp |
O(1) |
O(1) |
| 198 |
Medium |
House Robber |
198-house-robber.cpp |
O(n) |
O(n) |
| 200 |
Medium |
Number of Islands |
200-number-of-islands.cpp |
O(m*n) |
O(m*n) |
| 201 |
Medium |
Bitwise AND of Numbers Range |
201-bitwise-and-of-numbers-range.cpp |
O(log(n)) |
O(1) |
| 202 |
Easy |
Happy Number |
202-happy-number.cpp |
O(n) |
O(1) |
| 205 |
Easy |
Isomorphic Strings |
205-isomorphic-strings.cpp |
O(n) |
O(1) |
| 206 |
Easy |
Reverse Linked List |
206-reverse-linked-list.cpp |
O(n) |
O(1) |
| 208 |
Medium |
Implement Trie (Prefix Tree) |
208-implement-trie-prefix-tree.cpp |
O(n) for { insert(word), search(word), startsWith(prefix) } |
O(n) |
| 213 |
Medium |
House Robber II |
213-house-robber-ii.cpp |
O(n) |
O(n) |
| 215 |
Medium |
Kth Largest Element in an Array |
215-kth-largest-element-in-an-array.cpp |
O(n*log(k)) |
O(k) |
| 217 |
Easy |
Contains Duplicate |
217-contains-duplicate.cpp |
O(n) |
O(n) |
| 218 |
Hard |
The Skyline Problem |
218-the-skyline-problem.cpp |
O(n*log(n)) |
O(n) |
| 221 |
Medium |
Maximal Square |
221-maximal-square.cpp |
O(m*n) |
O(m*n) |
| 231 |
Easy |
Power of Two |
231-power-of-two.cpp |
O(1) |
O(1) |
| 234 |
Easy |
Palindrome Linked List |
234-palindrome-linked-list.cpp |
O(n) |
O(n) |
| 235 |
Medium |
Lowest Common Ancestor of a Binary Search Tree |
235-lowest-common-ancestor-of-a-binary-search-tree.cpp |
O(h) |
O(h) or O(1) with tail-call optimization |
| 238 |
Medium |
Product of Array Except Self |
238-product-of-array-except-self.cpp |
O(n) |
O(n) |
| 268 |
Easy |
Missing Number |
268-missing-number.cpp |
O(n) |
O(1) |
| 278 |
Easy |
First Bad Version |
278-first-bad-version.cpp |
O(log(n)) |
O(1) |
| 283 |
Easy |
Move Zeroes |
283-move-zeroes.cpp |
O(n) |
O(1) |
| 299 |
Medium |
Bulls and Cows |
299-bulls-and-cows.cpp |
O(n) |
O(1) |
| 300 |
Medium |
Longest Increasing Subsequence |
300-longest-increasing-subsequence.cpp |
O(n*log(n)) |
O(n) |
| 322 |
Medium |
Coin Change |
322-coin-change.cpp |
O(K*M) |
O(K*M) |
| 326 |
Easy |
Power of Three |
326-power-of-three.cpp |
O(1) |
O(1) |
| 342 |
Easy |
Power of Four |
342-power-of-four.cpp |
O(1) |
O(1) |
| 344 |
Easy |
Reverse String |
344-reverse-string.cpp |
O(n) |
O(1) |
| 347 |
Medium |
Top K Frequent Elements |
347-top-k-frequent-elements.cpp |
O(n) |
O(n) |
| 349 |
Easy |
Intersection of Two Arrays |
349-intersection-of-two-arrays.cpp |
O(n1+n2) |
O(n1+n2) |
| 350 |
Easy |
Intersection of Two Arrays II |
350-intersection-of-two-arrays-ii.cpp |
O(n1+n2) |
O(n1+n2) |
| 373 |
Medium |
Find K Pairs with Smallest Sums |
373-find-k-pairs-with-smallest-sums.cpp |
O(k*log(k)) |
O(k) |
| 383 |
Easy |
Ransom Note |
383-ransom-note.cpp |
O(m+n) |
O(1) |
| 387 |
Easy |
First Unique Character in a String |
387-first-unique-character-in-a-string.cpp |
O(n) |
O(1) |
| 392 |
Easy |
Is Subsequence |
392-is-subsequence.cpp |
O(m+n) |
O(1) |
| 394 |
Medium |
Decode String |
394-decode-string.cpp |
O(n) |
O(n) |
| 409 |
Easy |
Longest Palindrome |
409-longest-palindrome.cpp |
O(n) |
O(1) |
| 438 |
Medium |
Find All Anagrams in a String |
438-find-all-anagrams-in-a-string.cpp |
O(m+n) |
O(m) |
| 496 |
Easy |
Next Greater Element I |
496-next-greater-element-i.cpp |
O(n1+n2) |
O(n1+n2) |
| 503 |
Medium |
Next Greater Element II |
503-next-greater-element-ii.cpp |
O(n) |
O(n) |
| 509 |
Easy |
Fibonacci Number |
509-fibonacci-number.cpp |
O(log(n)) |
O(log(n)) |
| 525 |
Medium |
Contiguous Array |
525-contiguous-array.cpp |
O(n) |
O(n) |
| 542 |
Medium |
01 Matrix |
542-01-matrix.cpp |
O(m*n) |
O(m*n) |
| 543 |
Easy |
Diameter of Binary Tree |
543-diameter-of-binary-tree.cpp |
O(n) |
O(n) |
| 557 |
Easy |
Reverse Words in a String III |
557-reverse-words-in-a-string-iii.cpp |
O(n) |
O(1) |
| 560 |
Medium |
Subarray Sum Equals K |
560-subarray-sum-equals-k.cpp |
O(n) |
O(n) |
| 565 |
Medium |
Array Nesting |
565-array-nesting.cpp |
O(n) |
O(n) |
| 566 |
Easy |
Reshape the Matrix |
566-reshape-the-matrix.cpp |
O(m*n) |
O(m*n) |
| 567 |
Medium |
Permutation in String |
567-permutation-in-string.cpp |
O(n1+n2) |
O(1) |
| 587 |
Hard |
Erect the Fence |
587-erect-the-fence.cpp |
O(n*log(n)) |
O(n) |
| 589 |
Easy |
N-ary Tree Preorder Traversal |
589-n-ary-tree-preorder-traversal.cpp |
O(n) |
O(n) |
| 617 |
Easy |
Merge Two Binary Trees |
617-merge-two-binary-trees.cpp |
O(n1+n2) |
O(n1+n2) |
| 647 |
Medium |
Palindromic Substrings |
647-palindromic-substrings.cpp |
O(n^2) |
O(1) |
| 678 |
Medium |
Valid Parenthesis String |
678-valid-parenthesis-string.cpp |
O(n) |
O(1) |
| 692 |
Medium |
Top K Frequent Words |
692-top-k-frequent-words.cpp |
O(n*log(k)) |
O(n) |
| 695 |
Medium |
Max Area of Island |
695-max-area-of-island.cpp |
O(m*n) |
O(m*n) |
| 704 |
Easy |
Binary Search |
704-binary-search.cpp |
O(log(n)) |
O(1) |
| 724 |
Easy |
Find Pivot Index |
724-find-pivot-index.cpp |
O(n) |
O(1) |
| 733 |
Easy |
Flood Fill |
733-flood-fill.cpp |
O(m*n) |
O(m*n) |
| 739 |
Medium |
Daily Temperatures |
739-daily-temperatures.cpp |
O(n) |
O(n) |
| 746 |
Easy |
Min Cost Climbing Stairs |
746-min-cost-climbing-stairs.cpp |
O(n) |
O(n) |
| 764 |
Medium |
Largest Plus Sign |
764-largest-plus-sign.cpp |
O(n^2) |
O(n^2) |
| 784 |
Medium |
Letter Case Permutation |
784-letter-case-permutation.cpp |
O(n*2^n) |
O(n*2^n) |
| 844 |
Easy |
Backspace String Compare |
844-backspace-string-compare.cpp |
O(n) |
O(1) |
| 848 |
Medium |
Shifting Letters |
848-shifting-letters.cpp |
O(n) |
O(n) |
| 865 |
Medium |
Smallest Subtree with all the Deepest Nodes |
865-smallest-subtree-with-all-the-deepest-nodes.cpp |
O(n) |
O(n) |
| 876 |
Easy |
Middle of the Linked List |
876-middle-of-the-linked-list.cpp |
O(n) |
O(1) |
| 899 |
Hard |
Orderly Queue |
899-orderly-queue.cpp |
O(n^2) |
O(n) |
| 917 |
Easy |
Reverse Only Letters |
917-reverse-only-letters.cpp |
O(n) |
O(n) |
| 929 |
Easy |
Unique Email Addresses |
929-unique-email-addresses.cpp |
O(n) |
O(n) |
| 977 |
Easy |
Squares of a Sorted Array |
977-squares-of-a-sorted-array.cpp |
O(n) |
O(n) |
| 978 |
Medium |
Longest Turbulent Subarray |
978-longest-turbulent-subarray.cpp |
O(n) |
O(1) |
| 994 |
Medium |
Rotting Oranges |
994-rotting-oranges.cpp |
O(m*n) |
O(m*n) |
| 1008 |
Medium |
Construct Binary Search Tree from Preorder Traversal |
1008-construct-binary-search-tree-from-preorder-traversal.cpp |
O(n*log(n)) maybe? |
O(n) |
| 1011 |
Medium |
Capacity To Ship Packages Within D Days |
1011-capacity-to-ship-packages-within-d-days.cpp |
O(n*log(sum(W)-max(W))), where W = the weights of packages |
O(1) |
| 1046 |
Easy |
Last Stone Weight |
1046-last-stone-weight.cpp |
O(n*log(n)) |
O(n) |
| 1137 |
Easy |
N-th Tribonacci Number |
1137-n-th-tribonacci-number.cpp |
O(n) |
O(n) |
| 1143 |
Medium |
Longest Common Subsequence |
1143-longest-common-subsequence.cpp |
O(n1*n2) |
O(n1*n2) |
| 1189 |
Easy |
Maximum Number of Balloons |
1189-maximum-number-of-balloons.cpp |
O(n) |
O(1) |
| 1426 |
Easy |
Counting Elements |
1426-counting-elements.cpp |
O(n) |
O(n) |
| 1427 |
Easy |
Perform String Shifts |
1427-perform-string-shifts.cpp |
O(m+n) |
O(n) |
| 1428 |
Medium |
Leftmost Column with at Least a One |
1428-leftmost-column-with-at-least-a-one.cpp |
O(r+c) |
O(1) |
| 1429 |
Medium |
First Unique Number |
1429-first-unique-number.cpp |
O(1) for { showFirstUnique(), add(value) } |
O(n) |
| 1430 |
Medium |
Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree |
1430-check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree.cpp |
O(n) |
O(n) |
| 1475 |
Easy |
Final Prices With a Special Discount in a Shop |
1475-final-prices-with-a-special-discount-in-a-shop.cpp |
O(n) |
O(n) |
| 1480 |
Easy |
Running Sum of 1d Array |
1480-running-sum-of-1d-array.cpp |
O(n) |
O(n) |
| 1629 |
Easy |
Slowest Key |
1629-slowest-key.cpp |
O(n) |
O(1) |
| 1944 |
Hard |
Number of Visible People in a Queue |
1944-number-of-visible-people-in-a-queue.cpp |
O(n) |
O(n) |
| 1985 |
Medium |
Find the Kth Largest Integer in the Array |
1985-find-the-kth-largest-integer-in-the-array.cpp |
O(n), on average |
O(1) |
| 2487 |
Medium |
Remove Nodes From Linked List |
2487-remove-nodes-from-linked-list.cpp |
O(n) |
O(1) |