# | Problem | Solution | Time comp. | Space com. | Notes |
---|---|---|---|---|---|
1 | Two Sum | O(n) | O(n) | Array, Hash Table | |
7 | Reverse Integer | O(log n) | O(1) | Math, Array | |
9 | Palindrome Number | O(log n) | O(1) | Math, Array | |
13 | Roman to Integer | O(n) | O(1) | Math, String, Hash Table | |
14 | Longest Common Prefix | O(n * min(s)) | O(1) | String, Array | |
20 | Valid Parentheses | O(n) | O(n) | String, Stack | |
21 | Merge Two Sorted Lists | O(n+m) | O(1) | Linked List | |
26 | Remove Duplicates from Sorted Array | JS | O(n) | O(1) | Array, Two Pointers |
27 | Remove Element | JS | O(n) | O(1) | Array, Two Pointers |
28 | Implement strStr() | JS | O(n*m) | O(n) | String, Two Pointers |
35 | Search Insert Position | O(log n) | O(1) | Array, Binary Search | |
38 | Count and Say | JS | ? | ? | String |
53 | Maximum Subarray | O(n) | O(1) | Array, Dynamic Programming, Divide and Conquer | |
58 | Length of Last Word | JS | O(n) | O(1) | String |
66 | Plus One | JS | O(n) | O(1) | Array |
67 | Add Binary | O(Max(n,m)) | O(Max(n,m))_ | Math, String | |
69 | Sqrt(x) | JS | O(log n) | O(1) | Math, Binary Search |
70 | Climbing Stairs | JS | O(n) | O(1) | Dynamic Programming |
83 | Remove Duplicates from Sorted List | JS | O(n) | O(1) | Linked List |
88 | Merge Sorted Array | JS | O(n+m) | O(1) | Array, Two Pointers |
100 | Same Tree | JS | O(n) | O(1) | Tree, Depth-first Search |
101 | Symmetric Tree | JS | O(n) | O(n) | Tree, DFS, BFS |
102 | Binary Tree Level Order Traversal | O(n) | O(n) | Tree, BFS | |
104 | Maximum Depth of Binary Tree | JS | O(n) | O(n) | Tree, DFS |
112 | Path Sum | O(n) | O(n) | Tree, DFS | |
118 | Pascal's Triangle | JS | O(n^2) | O(n^2) | Array |
119 | Pascal's Triangle II | O(n^2) | O(n) | Array | |
121 | Best Time to Buy and Sell Stock | O(n) | O(1) | Array, Dynamic Programming | |
171 | Excel Sheet Column Number | O(n) | O(1) | Math | |
242 | Valid Anagram | O(n) | O(1) | Hash Table, Sort | |
303 | Range Sum Query - Immutable | O(n) | O(n) | Dynamic Programming | |
349 | Intersection of Two Arrays | O(n) | O(n) | Hash Table, Two Pointers, Binary Search, Sort | |
733 | Flood Fill | O(n) | O(n) | BFS, DFS | |
917 | Reverse Only Letter | O(n) | O(1) | String | |
1184 | Distance Between Bus Stops | O(n) | O(1) | Array | |
1189 | Maximum Number of Balloons | O(n) | O(1) | Hash Table, String | |
1200 | Minimum absolute Difference | O(n * log n) | O(n) | Array | |
1208 | Get Equal Substrings within Budget | O(n) | O(1) | Array, Sliding Window | |
1209 | Remove All Adjacent Duplicates in String II | O(n) | O(n) | Array, Stack, Two Pointers |
# | Problem | Solution | Time comp. | Space com. | Notes |
---|---|---|---|---|---|
2 | Add Two Numbers | O(n) | O(n) | Linked List, Math | |
3 | Longest Substring without Repeating Chars | O(n) | O(min(n,m)) | Hash Table, Two Pointers, String, Sliding Window | |
8 | String to Integer (atoi) | O(n) | O(1) | Math, String | |
11 | Container with Most Water | O(n) | O(1) | Array, Two Pointers | |
15 | 3Sum | JS | O(n^2) | O(n^2) | Array, Two Pointers |
17 | Letter Combinations of Phone Number | ||||
19 | Remove Nth Node from End of List | O(n) | O(1) | Linked List, Two Pointers | |
24 | Swap Nodes in Pairs | O(n) | O(1) | Linked List | |
31 | Next Permutation | O(n) | O(1) | Array | |
34 | Find First and Last Position of Element in Sorted Array | O(log n) | O(1) | Array, Binary Search | |
36 | Valid Sudoku | JS | O(1) | O(1) | Hash Table |
48 | Rotate Image | O(n) | O(1) | Array | |
54 | Spiral Matrix | O(n) | O(n) | Array | |
59 | Spiral Matrix II | O(n) | O(n) | Array | |
64 | Minimum Path Sum | O(n) | O(1) | Array, Dynamic Programming | |
74 | Search a 2D Matrix | O(log(m) + log(n)) | O(1) | Array, Binary Search | |
75 | Sort Colors | O(n) | O(1) | Array, Two Pointers, Sort | |
113 | Path Sum II | O(n) | O(depth*2^depth) | Tree, DFS | |
120 | Triangle | O(n) | O(log n) | Array, Dynamic Programming | |
129 | Sum Root to Leaf Numbers | O(n) | O(n) | Tree, DFS | |
304 | Range Sum Query 2D - Immutable | Dynamic Programming | |||
319 | Bulb Switcher | O(1) | O(1) | Math, Brainteaser | |
438 | Find All Anagrams | O(n) | O(1) | Hash Table, Sliding Window, Two Pointers | |
486 | Predict the Winner | ? | ? | Dynamic Programming, Minmax | |
508 | Most Frequent Subtree Sum | O(n) | O(n) | Hash Table, Tree, DFS | |
567 | Permutation in String | O(n) | O(1) | Two Pointers, Sliding Window, Hash Table | |
622 | Design Circular Queue | N/A | N/A | Design, Queue | |
865 | Smallest Subtree with all the Deepest Nodes | O(n) | O(n) | Tree, DFS | |
988 | Smallest String Starting from Leaf | O(n * log n) | O(n) | Tree, DFS | |
1080 | Insufficient Nodes in Root to Leaf Paths | O(n) | O(n) | Tree, DFS | |
1219 | Path with Maximum Gold | O(nm3^(m*n)) | O(n) | DFS, Backtracking |
# | Problem | Solution | Time comp. | Space com. | Notes |
---|---|---|---|---|---|
4 | Median of Two Sorted Arrays | JS | O(log min(n, m)) | O(1) | Array, Binary Search, Divide and Conquer |
10 | Regular Expression Matching | JS | O(n * m) | O(n * m) | String, Dynamic Programming, Backtracking |
23 | Merge k Sorted Lists | Linked List, Divide and Conquer, Heap |
Due to time concerns, I only add a small link to newly added problems. I can either do that or skip it altogether.
https://leetcode.com/problems/sum-of-left-leaves/
https://leetcode.com/problems/shift-2d-grid/
https://leetcode.com/problems/linked-list-random-node/
https://leetcode.com/problems/arranging-coins/
https://leetcode.com/problems/single-number-iii/
https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game/
https://leetcode.com/problems/unique-binary-search-trees/
https://leetcode.com/problems/multiply-strings/
https://leetcode.com/problems/path-sum-iii/
https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/
https://leetcode.com/problems/find-common-characters/
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/
- Minimum Cost to Make at Least One Valid Path in a Grid python solution
https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/
https://leetcode.com/problems/remove-linked-list-elements/
https://leetcode.com/problems/daily-temperatures/
https://leetcode.com/problems/maximum-path-quality-of-a-graph/
https://leetcode.com/problems/iterator-for-combination
https://leetcode.com/problems/largest-divisible-subset/
https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/
https://leetcode.com/problems/unique-paths/
https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array
https://leetcode.com/problems/hamming-distance/
https://leetcode.com/problems/rotate-list/
https://leetcode.com/problems/wiggle-sort-ii/
https://leetcode.com/problems/single-element-in-a-sorted-array/
https://leetcode.com/problems/n-queens/
https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal
https://leetcode.com/problems/delete-node-in-a-bst/
https://leetcode.com/problems/largest-component-size-by-common-factor/
https://leetcode.com/problems/interval-list-intersections/
https://leetcode.com/problems/product-of-array-except-self/
https://leetcode.com/problems/count-of-smaller-numbers-after-self/
https://leetcode.com/problems/count-of-range-sum/
https://leetcode.com/problems/student-attendance-record-ii/
https://leetcode.com/problems/all-paths-from-source-to-target/
https://leetcode.com/problems/accounts-merge/
https://leetcode.com/problems/maximal-rectangle/
https://leetcode.com/problems/house-robber/
https://leetcode.com/problems/odd-even-linked-list/
https://leetcode.com/problems/maximum-product-subarray/
https://leetcode.com/problems/stream-of-characters/
https://leetcode.com/problems/house-robber-iii/
https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position/
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/
https://leetcode.com/problems/binary-tree-tilt/
https://leetcode.com/problems/jump-game-iii/
https://leetcode.com/problems/domino-and-tromino-tiling/
https://leetcode.com/problems/nth-magical-number/
https://leetcode.com/problems/partition-equal-subset-sum/
https://leetcode.com/problems/consecutive-characters/submissions/
https://leetcode.com/problems/range-sum-of-bst/submissions/
https://leetcode.com/problems/insertion-sort-list/
https://leetcode.com/problems/minimum-height-trees/
https://leetcode.com/problems/maximal-square/
https://leetcode.com/problems/numbers-at-most-n-given-digit-set/
https://leetcode.com/problems/power-of-two/submissions/
https://leetcode.com/problems/reorder-list/
https://leetcode.com/problems/course-schedule-ii/
https://leetcode.com/problems/merge-intervals/
https://leetcode.com/problems/k-closest-points-to-origin/
https://leetcode.com/problems/number-complement/
https://leetcode.com/problems/robot-bounded-in-circle/
https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/
https://leetcode.com/problems/cherry-pickup-ii/
https://leetcode.com/problems/insert-into-a-binary-search-tree/
https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/
https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/
https://leetcode.com/problems/count-words-obtained-after-adding-a-letter/
https://leetcode.com/problems/reverse-string/
https://leetcode.com/problems/reverse-words-in-a-string-iii/
https://leetcode.com/problems/jump-game-iv/
https://leetcode.com/problems/middle-of-the-linked-list/
https://leetcode.com/problems/maximize-distance-to-closest-person/
https://leetcode.com/problems/word-pattern/
https://leetcode.com/problems/max-area-of-island/
https://leetcode.com/problems/can-place-flowers/
https://leetcode.com/problems/merge-two-binary-trees/
https://leetcode.com/problems/populating-next-right-pointers-in-each-node/
https://leetcode.com/problems/linked-list-cycle-ii/
https://leetcode.com/problems/koko-eating-bananas/
https://leetcode.com/problems/reverse-linked-list/
https://leetcode.com/problems/combinations/
https://leetcode.com/problems/gas-station/
https://leetcode.com/problems/stone-game-iv/
https://leetcode.com/problems/sequential-digits/
https://leetcode.com/problems/detect-capital/
https://leetcode.com/problems/valid-mountain-array/
https://leetcode.com/problems/search-in-rotated-sorted-array/
https://leetcode.com/problems/all-elements-in-two-binary-search-trees/
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/
https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
https://leetcode.com/problems/design-add-and-search-words-data-structure/
https://leetcode.com/problems/backspace-string-compare/
https://leetcode.com/problems/largest-rectangle-in-histogram/
https://leetcode.com/problems/rotate-array/
https://leetcode.com/problems/richest-customer-wealth/
https://leetcode.com/problems/4sum-ii/
https://leetcode.com/problems/contiguous-array/
https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/
https://leetcode.com/problems/find-the-difference/
https://leetcode.com/problems/add-digits/
https://leetcode.com/problems/k-diff-pairs-in-an-array/
https://leetcode.com/problems/subarray-sum-equals-k/
https://leetcode.com/problems/copy-list-with-random-pointer/
https://leetcode.com/problems/simplify-path/
https://leetcode.com/problems/validate-stack-sequences/
https://leetcode.com/problems/remove-duplicate-letters/
https://leetcode.com/problems/broken-calculator/
https://leetcode.com/problems/boats-to-save-people/
https://leetcode.com/problems/two-city-scheduling/
https://leetcode.com/problems/binary-search/
https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/
https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
https://leetcode.com/problems/valid-palindrome-ii/
https://leetcode.com/problems/swapping-nodes-in-a-linked-list/
https://leetcode.com/problems/last-stone-weight/
https://leetcode.com/problems/kth-largest-element-in-a-stream/
https://leetcode.com/problems/top-k-frequent-elements/
https://leetcode.com/problems/baseball-game/
https://leetcode.com/problems/game-of-life/
https://leetcode.com/problems/search-in-a-binary-search-tree/
https://leetcode.com/problems/trim-a-binary-search-tree/
https://leetcode.com/problems/kth-smallest-element-in-a-bst/
https://leetcode.com/problems/binary-search-tree-iterator/
https://leetcode.com/problems/design-hashset/
https://leetcode.com/problems/design-underground-system/
https://leetcode.com/problems/fibonacci-number/
https://leetcode.com/problems/interleaving-string/
https://leetcode.com/problems/min-cost-climbing-stairs/
https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
https://leetcode.com/problems/unique-morse-code-words/
https://leetcode.com/problems/reduce-array-size-to-the-half/
https://leetcode.com/problems/first-unique-character-in-a-string/