Skip to content

Latest commit

 

History

History
2454 lines (1879 loc) · 297 KB

TagREADME.md

File metadata and controls

2454 lines (1879 loc) · 297 KB

Table of Contents

Array (126)

Leetcode# Problem Level Tags Time Space Language Sequence
277 277. Find the Celebrity.java Medium [Adjacency Matrix, Array, Graph, Greedy, Pruning] O(n) O(1) Java 0
41 41. First Missing Positive.java Hard [Analysis, Array, Edge Case] O(n) O(1) Java 1
N/A Missing Ranges.java Medium [Array] Java 2
N/A Summary Ranges.java Medium [Array] Java 3
N/A Triangle Count.java Medium [Array] Java 4
N/A Game of Life.java Medium [Array] Java 5
N/A The Spiral Matrix II.java Medium [Array] Java 6
766 766. Toeplitz Matrix.java Easy [Array] O(mn) O(1) Java 7
665 665. Non-decreasing Array.java Easy [Array] O(n) O(1) Java 8
896 896. Monotonic Array.java Easy [Array] Java 9
717 717. 1-bit and 2-bit Characters.java Easy [Array] Java 10
747 747. Largest Number At Least Twice of Others.java Easy [Array] Java 11
561 561. Array Partition I.java Easy [Array] O(nlogn) O(1) Java 12
78 78. Subsets.java Medium [Array, BFS, Backtracking, Bit Manipulation, DFS] O(2^n) O(2^n) Java 13
N/A Subsets II.java Medium [Array, BFS, Backtracking, DFS] O(2^n) Java 14
N/A Word Ladder II.java Hard [Array, BFS, Backtracking, DFS, Hash Table, String] Java 15
N/A Max Sum of Rectangle No Larger Than K.java Hard [Array, BST, Binary Search, DP, Queue, TreeSet] Java 16
N/A K Empty Slots.java Hard [Array, BST, TreeSet] Java 17
N/A Combination Sum IV.java Medium [Array, Backpack DP, DP] Java 18
N/A Combination Sum III.java Medium [Array, Backtracking, Combination, DFS] Java 19
39 39. Combination Sum.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(k) stack depth, if not counting result size Java 20
40 40. Combination Sum II.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(n) stack depth, if not counting result size Java 21
N/A Word Search.java Medium [Array, Backtracking, DFS] Java 22
485 485. Max Consecutive Ones.java Easy [Array, Basic Implementation] O(n) O(1) Java 23
119 119. Pascal's Triangle II.java Easy [Array, Basic Implementation] O(k^2), pascal triangle size O(k^2) Java 24
118 118. Pascal's Triangle.java Easy [Array, Basic Implementation, List] O(n^2) based on pascal triangle size O(n^2) Java 25
849 849. Maximize Distance to Closest Person.java Easy [Array, Basic Implementation, Two Pointers] O(n) O(1) Java 26
N/A Find Minimum in Rotated Sorted Array.java Medium [Array, Binary Search] Java 27
N/A Find Peak Element.java Medium [Array, Binary Search] Java 28
N/A Find Minimum in Rotated Sorted Array II.java Hard [Array, Binary Search] Java 29
N/A Search for a Range.java Medium [Array, Binary Search] Java 30
N/A Search a 2D Matrix.java Medium [Array, Binary Search] Java 31
88 88. Search in Rotated Sorted Array II.java Medium [Array, Binary Search] O(logn), worst O(n) O(1) Java 32
33 33. Search in Rotated Sorted Array.java Medium [Array, Binary Search] O(logn) O(1) Java 33
34 34. Find First and Last Position of Element in Sorted Array.java Medium [Array, Binary Search] O(logn) O(1) Java 34
287 287. Find the Duplicate Number.java Medium [Array, Binary Search, Binary Search on Value, Cycle Detection, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 35
N/A Median of Two Sorted Arrays.java Hard [Array, Binary Search, DFS, Divide and Conquer] Java 36
[lint] [lint]. 2 Sum II.java Medium [Array, Binary Search, Lint, Two Pointers] Java 37
N/A Maximum Average Subarray II.java Review [Array, Binary Search, PreSum] Java 38
N/A Minimum Size Subarray Sum.java Medium [Array, Binary Search, Subarray, Two Pointers] O(n) O(1) Java 39
N/A Subarray Sum II.java Hard [Array, Binary Search, Two Pointers] Java 40
N/A Two Sum II - Input array is sorted.java Medium [Array, Binary Search, Two Pointers] Java 41
169 169. Majority Element.java Easy [Array, Bit Manipulation, Divide and Conquer, Moore Voting, Sort] O(n) O(1) Java 42
N/A Missing Number.java Easy [Array, Bit Manipulation, Math] Java 43
448 448. Find All Numbers Disappeared in an Array.java Easy [Array, Bucket Sort] O(n) O(1) Java 44
N/A Triangles.java Medium [Array, Coordinate DP, DFS, DP, Memoization] Java 45
N/A Longest Increasing Continuous subsequence.java Easy [Array, Coordinate DP, DP] Java 46
62 62. Unique Path.java Medium [Array, Coordinate DP, DP] O(mn) O(mn), rolling array O(n) Java 47
64 64. Minimum Path Sum.java Medium [Array, Coordinate DP, DP] O(mn) O(n) rolling array Java 48
63 63. Unique Paths II.java Medium [Array, Coordinate DP, DP] O(mn) O(mn) Java 49
N/A Jump Game II.java Hard [Array, Coordinate DP, DP, Greedy] O(n) O(1) Java 50
N/A Longest Increasing Continuous subsequence II.java Medium [Array, Coordinate DP, DP, Memoization] Java 51
674 674. Longest Continuous Increasing Subsequence.java Easy [Array, Coordinate DP, DP, Sliding Window] O(n) O(1) Java 52
N/A Max Area of Island.java Easy [Array, DFS] Java 53
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 54
105 105. Construct Binary Tree from Preorder and Inorder Traversal.java Medium [Array, DFS, Divide and Conquer, Hash Table, Tree] O(n) O(n) Java 55
N/A Construct Binary Tree from Inorder and Postorder Traversal.java Medium [Array, DFS, Divide and Conquer, Tree] Java 56
689 689. Maximum Sum of 3 Non-Overlapping Subarrays.java Hard [Array, DP] O(n) O(n) Java 57
N/A Coins in a Line III.java Hard [Array, DP, Game Theory, Interval DP, Memoization] Java 58
N/A Coins in a Line II.java Medium [Array, DP, Game Theory, Memoization, MiniMax] Java 59
55 55. Jump Game.java Medium [Array, DP, Greedy] O(n) O(1) Java 60
N/A Maximum Subarray II.java Medium [Array, DP, Greedy, PreSum, Sequence DP, Subarray] Java 61
N/A Best Time to Buy and Sell Stock with Transaction Fee.java Medium [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(n), O(1) rolling array Java 62
122 122. Best Time to Buy and Sell Stock II.java Easy [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(1) greedy, O(n) dp Java 63
N/A Minimum Subarray.java Easy [Array, DP, Greedy, Sequence DP, Subarray] O(m) O(1) Java 64
N/A Maximal Rectangle.java Hard [Array, DP, Hash Table, Stack] Java 65
152 152. Maximum Product Subarray.java Medium [Array, DP, PreProduct, Subarray] O(n) O(1) Java 66
N/A Best Time to Buy and Sell Stock III.java Hard [Array, DP, Sequence DP] Java 67
121 121. Best Time to Buy and Sell Stock.java Easy [Array, DP, Sequence DP] Java 68
380 380. Insert Delete GetRandom O(1).java Medium [Array, Design, Hash Table] O(1) avg O(n) Java 69
244 244. Shortest Word Distance II.java Medium [Array, Design, Hash Table, Two Pointers] O(n) to build map, O(a + b) to query O(n) Java 70
245 245. Shortest Word Distance III.java Medium [Array, Design, Hash Table, Two Pointers] O(n) O(1) Java 71
N/A Rotate Image.java Medium [Array, Enumeration] Java 72
N/A Spiral Matrix.java Medium [Array, Enumeration] Java 73
621 621. Task Scheduler.java Medium [Array, Enumeration, Greedy, PriorityQueue, Queue] O(n) O(1) Java 74
149 149. Max Points on a Line.java Hard [Array, Geometry, Hash Table, Math] O(n^2) O() Java 75
1267 1267. Count Servers that Communicate.java Medium [Array, Graph] O(mn) O(m + n) Java 76
1007 1007. Minimum Domino Rotations For Equal Row.java Medium [Array, Greedy] O(n) O(1) Java 77
605 605. Can Place Flowers.java Easy [Array, Greedy] O(n) O(1) Java 78
1053 1053. Previous Permutation With One Swap.java Medium [Array, Greedy, Permutation] O(n) O(1) Java 79
219 219. Contains Duplicate II.java Easy [Array, Hash Table] O(n) O(n) Java 80
217 217. Contains Duplicate.java Easy [Array, Hash Table] O(n) O(1) Java 81
1 1. Two Sum.java Easy [Array, Hash Table] O(n) O(n) Java 82
[lint] [lint]. Anagrams.java Medium [Array, Hash Table, Lint] O(n) O(n) Java 83
[lint] [lint]. Subarray Sum.java Easy [Array, Hash Table, Lint, PreSum, Subarray] O(n) O(n) Java 84
N/A Submatrix Sum.java Medium [Array, Hash Table, PreSum] Java 85
560 560. Subarray Sum Equals K.java Medium [Array, Hash Table, PreSum, Subarray] O(n) O(n) Java 86
1146 1146. Snapshot Array.java Medium [Array, Hash Table, TreeMap] O(1) set, O(logn) get, O(x) snap, x = # of changes O(n * m), n = array size, m = # of snaps Java 87
N/A Longest Consecutive Sequence.java Hard [Array, Hash Table, Union Find] Java 88
N/A Number of Airplane in the sky.java Medium [Array, Interval, PriorityQueue, Sort, Sweep Line] Java 89
[lint] [lint]. Product of Array Exclude Itself.java Medium [Array, Lint] Java 90
[lint] [lint]. Recover Rotated Sorted Array.java Easy [Array, Lint] Java 91
N/A [tool] Quick Select - Median.java Easy [Array, Lint, Quick Select, Quick Sort, Two Pointers] O(n) O(logN) Java 92
[lint] [lint]. Unique Characters.java Easy [Array, Lint, String] Java 93
[lint] [lint]. 3 Sum Closest.java Medium [Array, Lint, Two Pointers] Java 94
N/A Plus One.java Easy [Array, Math] Java 95
N/A Friends Of Appropriate Ages.java Medium [Array, Math] Java 96
N/A Largest Rectangle in Histogram.java Hard [Array, Monotonous Stack, Stack] Java 97
229 229. Majority Element II.java Medium [Array, Moore Voting] O(n) (1) Java 98
N/A Sort Colors.java Medium [Array, Partition, Quick Sort, Sort, Two Pointers] Java 99
31 31. Next Permutation.java Medium [Array, Permutation] O(n) O(1) Java 100
238 238. Product of Array Except Self.java Medium [Array, PreProduct] O(n) O(1) Java 101
724 724. Find Pivot Index.java Easy [Array, PreSum] O(n) O(1) Java 102
414 414. Third Maximum Number.java Easy [Array, PriorityQueue] Java 103
56 56. Merge Intervals.java Medium [Array, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 104
57 57. Insert Interval.java Hard [Array, PriorityQueue, Sort, Sweep Line] O(n) O(n) Java 105
N/A Partition Array.java Medium [Array, Quick Sort, Sort, Two Pointers] Java 106
189 189. Rotate Array.java Easy [Array, Rotation] Java 107
1040 1040. Moving Stones Until Consecutive II.java Medium [Array, Sliding Window] O(nlogn) O(n) Java 108
N/A Wiggle Sort.java Medium [Array, Sort] Java 109
N/A The Smallest Difference.java Medium [Array, Sort, Two Pointers] Java 110
259 259. 3Sum Smaller.java Medium [Array, Sort, Two Pointers] Java 111
15 15. 3Sum.java Medium [Array, Sort, Two Pointers] O(n^2) Java 112
42 42. Trapping Rain Water.java Hard [Array, Stack, Two Pointers] O(n) O(1) Java 113
1170 1170. Compare Strings by Frequency of the Smallest Character.java Easy [Array, String] O(m + n) O(m + n) Java 114
N/A Maximum Average Subarray I.java Easy [Array, Subarray] O(n) O(1) Java 115
N/A My Calendar I.java Medium [Array, TreeMap] Java 116
N/A Container With Most Water.java Medium [Array, Two Pointers] Java 117
N/A Partition Array by Odd and Even.java Easy [Array, Two Pointers] Java 118
80 80.Remove Duplicates from Sorted Array II.java Medium [Array, Two Pointers] Java 119
26 26.Remove Duplicates from Sorted Array.java Easy [Array, Two Pointers] Java 120
977 977. Squares of a Sorted Array.java Easy [Array, Two Pointers] O(n) O(n) Java 121
88 88. Merge Sorted Array.java Easy [Array, Two Pointers] O(n) O(1) Java 122
243 243. Shortest Word Distance.java Easy [Array, Two Pointers] O(n) O(1) Java 123
283 283. Move Zeroes.java Easy [Array, Two Pointers] O(n) O(1) Java 124
611 611. Valid Triangle Number.java Medium [Array, Two Pointers] O(n^2) O(logn), sorting space Java 125

DFS (121)

Leetcode# Problem Level Tags Time Space Language Sequence
78 78. Subsets.java Medium [Array, BFS, Backtracking, Bit Manipulation, DFS] O(2^n) O(2^n) Java 0
N/A Subsets II.java Medium [Array, BFS, Backtracking, DFS] O(2^n) Java 1
N/A Word Ladder II.java Hard [Array, BFS, Backtracking, DFS, Hash Table, String] Java 2
N/A Combination Sum III.java Medium [Array, Backtracking, Combination, DFS] Java 3
39 39. Combination Sum.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(k) stack depth, if not counting result size Java 4
40 40. Combination Sum II.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(n) stack depth, if not counting result size Java 5
N/A Word Search.java Medium [Array, Backtracking, DFS] Java 6
N/A Median of Two Sorted Arrays.java Hard [Array, Binary Search, DFS, Divide and Conquer] Java 7
N/A Triangles.java Medium [Array, Coordinate DP, DFS, DP, Memoization] Java 8
N/A Max Area of Island.java Easy [Array, DFS] Java 9
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 10
105 105. Construct Binary Tree from Preorder and Inorder Traversal.java Medium [Array, DFS, Divide and Conquer, Hash Table, Tree] O(n) O(n) Java 11
N/A Construct Binary Tree from Inorder and Postorder Traversal.java Medium [Array, DFS, Divide and Conquer, Tree] Java 12
254 254. Factor Combinations.java Medium [BFS, Backtracking, DFS] O(x), x is the # of results O(y), y is all ongoing candidates in queue Java 13
269 269. Alien Dictionary.java Hard [BFS, Backtracking, DFS, Graph, Topological Sort] O(n), n = # of graph edges O(n) Java 14
207 207. Course Schedule.java Medium [BFS, Backtracking, DFS, Graph, Topological Sort] O(n) O(n) Java 15
46 46. Permutations.java Medium [BFS, Backtracking, DFS, Permutation] O(n!) O(n!) Java 16
987 987. Vertical Order Traversal of a Binary Tree.java Medium [BFS, Binary Tree, DFS, Hash Table, Tree] Java 17
N/A Walls and Gates.java Medium [BFS, DFS] Java 18
N/A The Maze.java Medium [BFS, DFS] Java 19
N/A Find the Connected Component in the Undirected Graph.java Medium [BFS, DFS] Java 20
301 301. Remove Invalid Parentheses.java Hard [BFS, DFS, DP] Java 21
297 297. Serialize and Deserialize Binary Tree.java Hard [BFS, DFS, Deque, Design, Divide and Conquer, Tree] O(n) O(n) Java 22
785 785. Is Graph Bipartite.java Medium [BFS, DFS, Garph] O(n) O(n) Java 23
1161 1161. Maximum Level Sum of a Binary Tree.java Medium [BFS, DFS, Graph] O(n) visit all nodes O(n) Java 24
133 133. Clone Graph.java Medium [BFS, DFS, Graph] O(n) O(n) Java 25
743 743. Network Delay Time.java Medium [BFS, DFS, Graph, Heap, PQ] O(nlogn) O(n) Java 26
1203 1203. Sort Items by Groups Respecting Dependencies.java Hard [BFS, DFS, Graph, Topological Sort] O(V + E) to traverse the graph, #nodes + #edges O(V + E) Java 27
210 210. Course Schedule II.java Medium [BFS, DFS, Graph, Topological Sort] O(n) O(n) Java 28
N/A Redundant Connection.java Medium [BFS, DFS, Graph, Tree, Union Find] Java 29
N/A Number of Connected Components in an Undirected Graph.java Medium [BFS, DFS, Graph, Union Find] Java 30
261 261. Graph Valid Tree.java Medium [BFS, DFS, Graph, Union Find] Java 31
399 399. Evaluate Division.java Medium [BFS, DFS, Graph, Union Find] Java 32
314 314. Binary Tree Vertical Order Traversal.java Medium [BFS, DFS, Hash Table, Tree] O(n) O(n) Java 33
[tool] [tool]. Topological Sorting.java Medium [BFS, DFS, Lint, Topological Sort] O(V + E) O(V + E) Java 34
N/A Surrounded Regions.java Medium [BFS, DFS, Matrix DFS, Union Find] Java 35
200 200. Number of Islands.java Medium [BFS, DFS, Matrix DFS, Union Find] O(n) O(n) Java 36
339 339. Nested List Weight Sum.java Easy [BFS, DFS, NestedInteger] O(n) O(h), h = levels Java 37
N/A The Maze II.java Medium [BFS, DFS, PriorityQueue] Java 38
N/A The Maze III.java Hard [BFS, DFS, PriorityQueue] Java 39
144 144. Binary Tree Preorder Traversal.java Medium [BFS, DFS, Stack, Tree] O(n) O(n) Java 40
N/A Invert Binary Tree.java Easy [BFS, DFS, Tree] Java 41
102 102. Binary Tree Level Order Traversal.java Medium [BFS, DFS, Tree] O(n) O(n) Java 42
111 111. Minimum Depth of Binary Tree.java Easy [BFS, DFS, Tree] O(n) O(n) Java 43
199 199. Binary Tree Right Side View.java Medium [BFS, DFS, Tree] O(n) O(n) Java 44
515 515. Find Largest Value in Each Tree Row.java Medium [BFS, DFS, Tree] O(n) O(n) Java 45
100 100. Same Tree.java Easy [BFS, DFS, Tree] O(n) O(logn) Java 46
1123 1123. Lowest Common Ancestor of Deepest Leaves.java Medium [BFS, DFS, Tree] O(n) O(n) Java 47
101 101. Symmetric Tree.java Easy [BFS, DFS, Tree] O(n) O(n) Java 48
N/A Convert Sorted List to Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Linked List] Java 49
426 426. Convert Binary Search Tree to Sorted Doubly Linked List.java Medium [BST, DFS, Divide and Conquer, Linked List, Tree] O(n) O(1) Java 50
98 98. Validate Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Tree] O(n) O(logn) Java 51
N/A Kth Smallest Element in a BST.java Medium [BST, DFS, Stack, Tree] Java 52
N/A Recover Binary Search Tree.java Hard [BST, DFS, Tree] Java 53
235 235. Lowest Common Ancestor of a Binary Search Tree.java Easy [BST, DFS, Tree] O(logn) O(logn) Java 54
322 322. Coin Change.java Medium [Backpack DP, DFS, DP, Memoization] O(n * S) O(S) Java 55
257 257. Binary Tree Paths.java Easy [Backtracking, Binary Tree, DFS] O(n) O(nlogn) Java 56
N/A Combinations.java Medium [Backtracking, Combination, DFS] Java 57
N/A Robot Room Cleaner.java Hard [Backtracking, DFS] Java 58
131 131. Palindrome Partitioning.java Medium [Backtracking, DFS] O(2^n) O(n^2) Java 59
1219 1219. Path with Maximum Gold.java Medium [Backtracking, DFS] O(n^2) O(n) recursive depth Java 60
47 47. Permutations II.java Medium [Backtracking, DFS] Java 61
N/A Flip Game II.java Medium [Backtracking, DFS, DP] Java 62
140 140. Word Break II.java Hard [Backtracking, DFS, DP, Hash Table, Memoization] O(n!) O(n!) Java 63
N/A Expression Add Operators.java Hard [Backtracking, DFS, Divide and Conquer, String] O(4^n) O(4^n) Java 64
332 332. Reconstruct Itinerary.java Medium [Backtracking, DFS, Graph] O(n^n) O(�m) Java 65
22 22. Generate Parentheses.java Medium [Backtracking, DFS, Sequence DFS, String] O(2^n) O(2^n) Java 66
N/A Restore IP Addresses.java Medium [Backtracking, DFS, String] Java 67
N/A Path Sum II.java Easy [Backtracking, DFS, Tree] Java 68
N/A Word Search II.java Hard [Backtracking, DFS, Trie] Java 69
N/A Find Peak Element II.java Hard [Binary Search, DFS, Divide and Conquer] Java 70
222 222. Count Complete Tree Nodes.java Medium [Binary Search, DFS, Tree] O(n) O(h) Java 71
114 114. Flatten Binary Tree to Linked List.java Medium [Binary Tree, DFS] O(n) O(n), stacks Java 72
N/A Segment Tree Modify.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 73
N/A Segment Tree Query II.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 74
[lint] [lint]. Segment Tree Query.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 75
N/A Expression Evaluation.java Hard [Binary Tree, DFS, Expression Tree, Minimum Binary Tree, Stack] Java 76
N/A Convert Expression to Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 77
N/A Convert Expression to Reverse Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 78
N/A Longest Increasing Path in a Matrix.java Hard [Coordinate DP, DFS, DP, Memoization, Topological Sort] Java 79
N/A Flood Fill.java Easy [DFS] Java 80
N/A Target Sum.java Medium [DFS, DP] Java 81
741 741. Cherry Pickup.java Hard [DFS, DP] O(n^3) O(n^3), memo size Java 82
1043 1043. Partition Array for Maximum Sum.java Medium [DFS, DP, Graph, Memoization] O(n), calc memo[n] O(n) Java 83
516 516. Longest Palindromic Subsequence.java Medium [DFS, DP, Interval DP, Memoization] O(n^2) O(n^2) Java 84
1216 1216. Valid Palindrome III.java Hard [DFS, DP, Memoization, String] O(n^2) O(n^2) Java 85
698 698. Partition to K Equal Sum Subsets.java Medium [DFS, DP, Recursion] O(k^(n-k) * k!) O(n) Java 86
N/A House Robber III.java Medium [DFS, DP, Status DP, Tree] Java 87
124 124. Binary Tree Maximum Path Sum.java Hard [DFS, DP, Tree, Tree DP] O(n) O(logn) Java 88
N/A Fast Power.java Medium [DFS, Divide and Conquer] Java 89
N/A Binary Tree Longest Consecutive Sequence II.java Medium [DFS, Divide and Conquer, Double Recursive, Tree] Java 90
N/A Decode String.java Medium [DFS, Divide and Conquer, Stack] Java 91
N/A Subtree of Another Tree.java Easy [DFS, Divide and Conquer, Tree] Java 92
N/A Convert Sorted Array to Binary Search Tree.java Easy [DFS, Divide and Conquer, Tree] Java 93
N/A Populating Next Right Pointers in Each Node.java Medium [DFS, Divide and Conquer, Tree] Java 94
N/A Smallest Subtree with all the Deepest Nodes.java Medium [DFS, Divide and Conquer, Tree] O(n) O(n) Java 95
N/A Binary Tree Longest Consecutive Sequence.java Medium [DFS, Divide and Conquer, Tree] Java 96
1110 1110. Delete Nodes And Return Forest.java Medium [DFS, Divide and Conquer, Tree] O(n) O(logn) Java 97
N/A Path Sum III.java Easy [DFS, Double Recursive, Tree] Java 98
N/A Strobogrammatic Number II.java Medium [DFS, Enumeration, Math, Sequence DFS] Java 99
N/A Redundant Connection II.java Hard [DFS, Graph, Tree, Union Find] Java 100
N/A Cracking the Safe.java Hard [DFS, Greedy, Math] Java 101
694 694. Number of Distinct Islands.java Medium [DFS, Hash Table] O(n) O(n) Java 102
N/A Path Sum IV.java Medium [DFS, Hash Table, Tree] Java 103
721 721. Accounts Merge.java Medium [DFS, Hash Table, Union Find] Java 104
430 430. Flatten a Multilevel Doubly Linked List.java Medium [DFS, Linked List] O(n) O(1) Java 105
364 364. Nested List Weight Sum II.java Medium [DFS, NestedInteger] O(n), visit all nodes O(h), depth Java 106
1106 1106. Parsing A Boolean Expression.java Hard [DFS, Stack, String] Java 107
N/A Binary Tree Maximum Path Sum II.java Medium [DFS, Tree] Java 108
N/A Subtree.java Easy [DFS, Tree] Java 109
N/A Tweaked Identical Binary Tree.java Easy [DFS, Tree] Java 110
N/A Merge Two Binary Trees.java Easy [DFS, Tree] Java 111
N/A Populating Next Right Pointers in Each Node II.java Medium [DFS, Tree] O(n) O(1) Java 112
236 236. Lowest Common Ancestor of a Binary Tree.java Medium [DFS, Tree] O(n) O(n) Java 113
1008 1008. Construct Binary Search Tree from Preorder Traversal.java Medium [DFS, Tree] O(n) O(n) Java 114
104 104. Maximum Depth of Binary Tree.java Easy [DFS, Tree] Java 115
110 110. Balanced Binary Tree.java Easy [DFS, Tree] Java 116
112 112. Path Sum.java Easy [DFS, Tree] Java 117
1026 1026. Maximum Difference Between Node and Ancestor.java Medium [DFS, Tree] O(n) O(logn) Java 118
366 366. Find Leaves of Binary Tree.java Medium [DFS, Tree] O(n) O(h) Java 119
156 156. Binary Tree Upside Down.java Medium [DFS, Tree] O(n) O(h) Java 120

DP (94)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Max Sum of Rectangle No Larger Than K.java Hard [Array, BST, Binary Search, DP, Queue, TreeSet] Java 0
N/A Combination Sum IV.java Medium [Array, Backpack DP, DP] Java 1
N/A Triangles.java Medium [Array, Coordinate DP, DFS, DP, Memoization] Java 2
N/A Longest Increasing Continuous subsequence.java Easy [Array, Coordinate DP, DP] Java 3
62 62. Unique Path.java Medium [Array, Coordinate DP, DP] O(mn) O(mn), rolling array O(n) Java 4
64 64. Minimum Path Sum.java Medium [Array, Coordinate DP, DP] O(mn) O(n) rolling array Java 5
63 63. Unique Paths II.java Medium [Array, Coordinate DP, DP] O(mn) O(mn) Java 6
N/A Jump Game II.java Hard [Array, Coordinate DP, DP, Greedy] O(n) O(1) Java 7
N/A Longest Increasing Continuous subsequence II.java Medium [Array, Coordinate DP, DP, Memoization] Java 8
674 674. Longest Continuous Increasing Subsequence.java Easy [Array, Coordinate DP, DP, Sliding Window] O(n) O(1) Java 9
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 10
689 689. Maximum Sum of 3 Non-Overlapping Subarrays.java Hard [Array, DP] O(n) O(n) Java 11
N/A Coins in a Line III.java Hard [Array, DP, Game Theory, Interval DP, Memoization] Java 12
N/A Coins in a Line II.java Medium [Array, DP, Game Theory, Memoization, MiniMax] Java 13
55 55. Jump Game.java Medium [Array, DP, Greedy] O(n) O(1) Java 14
N/A Maximum Subarray II.java Medium [Array, DP, Greedy, PreSum, Sequence DP, Subarray] Java 15
N/A Best Time to Buy and Sell Stock with Transaction Fee.java Medium [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(n), O(1) rolling array Java 16
122 122. Best Time to Buy and Sell Stock II.java Easy [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(1) greedy, O(n) dp Java 17
N/A Minimum Subarray.java Easy [Array, DP, Greedy, Sequence DP, Subarray] O(m) O(1) Java 18
N/A Maximal Rectangle.java Hard [Array, DP, Hash Table, Stack] Java 19
152 152. Maximum Product Subarray.java Medium [Array, DP, PreProduct, Subarray] O(n) O(1) Java 20
N/A Best Time to Buy and Sell Stock III.java Hard [Array, DP, Sequence DP] Java 21
121 121. Best Time to Buy and Sell Stock.java Easy [Array, DP, Sequence DP] Java 22
301 301. Remove Invalid Parentheses.java Hard [BFS, DFS, DP] Java 23
N/A Perfect Squares.java Medium [BFS, DP, Math, Partition DP] Java 24
N/A Unique Binary Search Tree II.java Medium [BST, DP, Divide and Conquer, Tree] Java 25
N/A Unique Binary Search Tree.java Medium [BST, DP, Tree] Java 26
322 322. Coin Change.java Medium [Backpack DP, DFS, DP, Memoization] O(n * S) O(S) Java 27
N/A Backpack VI.java Medium [Backpack DP, DP] Java 28
N/A Backpack V.java Medium [Backpack DP, DP] Java 29
N/A Backpack II.java Medium [Backpack DP, DP] Java 30
N/A Backpack.java Medium [Backpack DP, DP] Java 31
N/A Backpack III.java Hard [Backpack DP, DP] Java 32
518 518. Coin Change 2.java Medium [Backpack DP, DP] O(n) O(n) Java 33
416 416. Partition Equal Subset Sum.java Medium [Backpack, DP] Java 34
N/A Flip Game II.java Medium [Backtracking, DFS, DP] Java 35
140 140. Word Break II.java Hard [Backtracking, DFS, DP, Hash Table, Memoization] O(n!) O(n!) Java 36
N/A Wildcard Matching.java Hard [Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String] Java 37
10 10. Regular Expression Matching.java Hard [Backtracking, DP, Double Sequence DP, Sequence DP, String] Java 38
N/A Russian Doll Envelopes.java Hard [Binary Search, Coordinate DP, DP] Java 39
N/A Longest Increasing Subsequence.java Medium [Binary Search, Coordinate DP, DP, Memoization] O(n^2) dp, O(nLogN) binary search O(n) Java 40
N/A Copy Books.java Hard [Binary Search, DP, Partition DP] Java 41
N/A Counting Bits.java Medium [Bit Manipulation, Bitwise DP, DP] Java 42
N/A Nim Game.java Easy [Brainteaser, DP, Game Theory] Java 43
1048 1048. Longest String Chain.java Medium [Bucket Sort, DP, Hash Table, Sort] O(n) O(n) Java 44
N/A Longest Increasing Path in a Matrix.java Hard [Coordinate DP, DFS, DP, Memoization, Topological Sort] Java 45
N/A Number of Longest Increasing Subsequence.java Medium [Coordinate DP, DP] O(n^2) Java 46
221 221. Maximal Square.java Medium [Coordinate DP, DP] O(mn) O(mn) Java 47
361 361. Bomb Enemy.java Medium [Coordinate DP, DP] O(mn) O(n) by calculating column sum Java 48
523 523. Continuous Subarray Sum.java Medium [Coordinate DP, DP, Math, PreSum, Subarray] O(n) O(k) Java 49
N/A Minimum Swaps To Make Sequences Increasing.java Medium [Coordinate DP, DP, Status DP] Java 50
N/A Target Sum.java Medium [DFS, DP] Java 51
741 741. Cherry Pickup.java Hard [DFS, DP] O(n^3) O(n^3), memo size Java 52
1043 1043. Partition Array for Maximum Sum.java Medium [DFS, DP, Graph, Memoization] O(n), calc memo[n] O(n) Java 53
516 516. Longest Palindromic Subsequence.java Medium [DFS, DP, Interval DP, Memoization] O(n^2) O(n^2) Java 54
1216 1216. Valid Palindrome III.java Hard [DFS, DP, Memoization, String] O(n^2) O(n^2) Java 55
698 698. Partition to K Equal Sum Subsets.java Medium [DFS, DP, Recursion] O(k^(n-k) * k!) O(n) Java 56
N/A House Robber III.java Medium [DFS, DP, Status DP, Tree] Java 57
124 124. Binary Tree Maximum Path Sum.java Hard [DFS, DP, Tree, Tree DP] O(n) O(logn) Java 58
N/A Stone Game.java Medium [DP] Java 59
N/A Ones and Zeroes.java Hard [DP] Java 60
N/A k Sum.java Hard [DP] Java 61
N/A Best Time to Buy and Sell Stock with Cooldown.java Medium [DP] Java 62
N/A Maximum Vacation Days.java Hard [DP] Java 63
N/A Burst Balloons.java Hard [DP, Divide and Conquer, Interval DP, Memoization] Java 64
N/A Longest Common Subsequence.java Medium [DP, Double Sequence DP, Sequence DP] Java 65
N/A Longest Common Substring.java Medium [DP, Double Sequence DP, Sequence DP, String] Java 66
72 72. Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, String] O(MN) Java 67
N/A K Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, Trie] Java 68
N/A Ugly Number II.java Medium [DP, Enumeration, Heap, Math, PriorityQueue] O(n) O(n) Java 69
639 639. Decode Ways II.java Hard [DP, Enumeration, Partition DP] O(n) O(n) Java 70
N/A Coins in a Line.java Medium [DP, Game Theory, Greedy] Java 71
N/A Frog Jump.java Hard [DP, Hash Table] Java 72
139 139. Word Break.java Medium [DP, Hash Table, Sequence DP] O(n^2) O(n) Java 73
727 727. Minimum Window Subsequence.java Hard [DP, Hash Table, Sliding Window, String, Two Pointers] O(n^2) O(1) Java 74
N/A Scramble String.java Hard [DP, Interval DP, String] Java 75
N/A Number Of Corner Rectangles.java Medium [DP, Math] Java 76
509 509. Fibonacci Number.java Easy [DP, Math, Memoization] Java 77
70 70. Climbing Stairs.java Easy [DP, Memoization, Sequence DP] Java 78
N/A Predict the Winner.java Medium [DP, MiniMax] Java 79
N/A Palindrome Partitioning II.java Hard [DP, Partition DP] Java 80
91 91. Decode Ways.java Medium [DP, Partition DP, String] O(n) O(n) Java 81
303 303. Range Sum Query - Immutable.java Easy [DP, PreSum] O(1) query, O(n) setup O(n) Java 82
304 304. Range Sum Query 2D - Immutable.java Medium [DP, PreSum] O(mn) build, O(1) query O(mn) Java 83
N/A Paint Fence.java Easy [DP, Sequence DP] O(n) O(n) Java 84
N/A Best Time to Buy and Sell Stock IV.java Hard [DP, Sequence DP] Java 85
N/A House Robber II.java Medium [DP, Sequence DP, Status DP] Java 86
198 198. House Robber.java Easy [DP, Sequence DP, Status DP] O(n) O(n) or rolling array O(1) Java 87
256 256. Paint House.java Easy [DP, Sequence DP, Status DP] O(nm), m = # of colors O(nm), or O(1) with rolling array Java 88
265 265. Paint House II.java Hard [DP, Sequence DP, Status DP] O(NK^2): O(K) with rolling array Java 89
N/A Palindromic Substrings.java Medium [DP, String] Java 90
N/A Distinct Subsequences.java Hard [DP, String] Java 91
N/A Interleaving String.java Hard [DP, String] Java 92
5 5. Longest Palindromic Substring.java Medium [DP, String] O(n^2) O(n^2) Java 93

Hash Table (86)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Word Ladder II.java Hard [Array, BFS, Backtracking, DFS, Hash Table, String] Java 0
105 105. Construct Binary Tree from Preorder and Inorder Traversal.java Medium [Array, DFS, Divide and Conquer, Hash Table, Tree] O(n) O(n) Java 1
N/A Maximal Rectangle.java Hard [Array, DP, Hash Table, Stack] Java 2
380 380. Insert Delete GetRandom O(1).java Medium [Array, Design, Hash Table] O(1) avg O(n) Java 3
244 244. Shortest Word Distance II.java Medium [Array, Design, Hash Table, Two Pointers] O(n) to build map, O(a + b) to query O(n) Java 4
245 245. Shortest Word Distance III.java Medium [Array, Design, Hash Table, Two Pointers] O(n) O(1) Java 5
149 149. Max Points on a Line.java Hard [Array, Geometry, Hash Table, Math] O(n^2) O() Java 6
219 219. Contains Duplicate II.java Easy [Array, Hash Table] O(n) O(n) Java 7
217 217. Contains Duplicate.java Easy [Array, Hash Table] O(n) O(1) Java 8
1 1. Two Sum.java Easy [Array, Hash Table] O(n) O(n) Java 9
[lint] [lint]. Anagrams.java Medium [Array, Hash Table, Lint] O(n) O(n) Java 10
[lint] [lint]. Subarray Sum.java Easy [Array, Hash Table, Lint, PreSum, Subarray] O(n) O(n) Java 11
N/A Submatrix Sum.java Medium [Array, Hash Table, PreSum] Java 12
560 560. Subarray Sum Equals K.java Medium [Array, Hash Table, PreSum, Subarray] O(n) O(n) Java 13
1146 1146. Snapshot Array.java Medium [Array, Hash Table, TreeMap] O(1) set, O(logn) get, O(x) snap, x = # of changes O(n * m), n = array size, m = # of snaps Java 14
N/A Longest Consecutive Sequence.java Hard [Array, Hash Table, Union Find] Java 15
987 987. Vertical Order Traversal of a Binary Tree.java Medium [BFS, Binary Tree, DFS, Hash Table, Tree] Java 16
314 314. Binary Tree Vertical Order Traversal.java Medium [BFS, DFS, Hash Table, Tree] O(n) O(n) Java 17
140 140. Word Break II.java Hard [Backtracking, DFS, DP, Hash Table, Memoization] O(n!) O(n!) Java 18
349 349. Intersection of Two Arrays.java Easy [Binary Search, Hash Table, Sort, Two Pointers] O(m + n) O(m + n) Java 19
350 350. Intersection of Two Arrays II.java Easy [Binary Search, Hash Table, Sort, Two Pointers] (n) (n) Java 20
981 981. Time Based Key-Value Store.java Medium [Binary Search, Hash Table, TreeMap] set O(1), get(logn) O(n) Java 21
136 136. Single Number.java Easy [Bit Manipulation, Hash Table] Java 22
1048 1048. Longest String Chain.java Medium [Bucket Sort, DP, Hash Table, Sort] O(n) O(n) Java 23
274 274.H-Index.java Medium [Bucket Sort, Hash Table, Sort] O(n) O(n) Java 24
694 694. Number of Distinct Islands.java Medium [DFS, Hash Table] O(n) O(n) Java 25
N/A Path Sum IV.java Medium [DFS, Hash Table, Tree] Java 26
721 721. Accounts Merge.java Medium [DFS, Hash Table, Union Find] Java 27
N/A Frog Jump.java Hard [DP, Hash Table] Java 28
139 139. Word Break.java Medium [DP, Hash Table, Sequence DP] O(n^2) O(n) Java 29
727 727. Minimum Window Subsequence.java Hard [DP, Hash Table, Sliding Window, String, Two Pointers] O(n^2) O(1) Java 30
146 146. LRU Cache.java Medium [Design, Doubly Linked List, Hash Table, Linked List] O(1) O(1) Java 31
N/A Perfect Rectangle.java Hard [Design, Geometry, Hash Table] Java 32
N/A ColorGrid.java Medium [Design, Hash Table] Java 33
N/A LFU Cache.java Hard [Design, Hash Table] Java 34
N/A Unique Word Abbreviation.java Medium [Design, Hash Table] Java 35
359 359. Logger Rate Limiter.java Easy [Design, Hash Table] O(1) O(n) Java 36
170 170. Two Sum III - Data structure design.java Easy [Design, Hash Table, Memoization] O(n) O(n) Java 37
N/A Design Search Autocomplete System.java Hard [Design, Hash Table, MinHeap, PriorityQueue, Trie] input: O(x), where x = possible words, constructor: O(mn) m = max length, n = # of words O(n^2), n = # of possible words, n = # of trie levels; mainlay saving the Map<S, freq> Java 38
36 36. Valid Sudoku.java Easy [Enumeration, Hash Table] (mn) (mn) Java 39
246 246. Strobogrammatic Number.java Easy [Enumeration, Hash Table, Math, Two Pointers] O(n) O(1) Java 40
N/A Rearrange String k Distance Apart.java Hard [Greedy, Hash Table, Heap] Java 41
767 767. Reorganize String.java Medium [Greedy, Hash Table, Heap, Sort, String] O(m), m = # of unique letters O(nLogm), n = length Java 42
N/A Remove Duplicate Letters.java Hard [Greedy, Hash Table, Stack] Java 43
N/A Rehashing.java Medium [Hash Table] Java 44
N/A 4Sum.java Medium [Hash Table] Java 45
N/A Contiguous Array.java Medium [Hash Table] Java 46
N/A Brick Wall.java Medium [Hash Table] O(mn) O(X), X = max wall width Java 47
N/A HashWithCustomizedClass(LinkedList).java Medium [Hash Table] Java 48
953 953. Verifying an Alien Dictionary.java Easy [Hash Table] O(nm) O(1) Java 49
299 299. Bulls and Cows.java Medium [Hash Table] O(n) O(n) Java 50
266 266. Palindrome Permutation.java Easy [Hash Table] O(n) O(n) Java 51
311 311. Sparse Matrix Multiplication.java Medium [Hash Table] O(mnk), where m = A.row, n = B.col, k = A.col = B.row O(1) extra Java 52
771 771. Jewels and Stones.java Easy [Hash Table] O(n) O(n) Java 53
463 463. Island Perimeter.java Easy [Hash Table] O(n) Java 54
205 205. Isomorphic Strings.java Easy [Hash Table] O(n) O(n) Java 55
760 760. Find Anagram Mappings.java Easy [Hash Table] O(n) O(n) Java 56
347 347. Top K Frequent Elements.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue] O(n) O(n) Java 57
692 692. Top K Frequent Words.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie] O(n) O(n) Java 58
N/A Majority Number III.java Medium [Hash Table, Linked List] Java 59
138 138. Copy List with Random Pointer.java Medium [Hash Table, Linked List] O(n) O(n) Java 60
340 340. Longest Substring with At Most K Distinct Characters.java Hard [Hash Table, LinkedHashMap, Sliding Window, String, Two Pointers] O(n) O(k) Java 61
[tool] [tool]. Hash Function.java Easy [Hash Table, Lint] O(1) get O(n) store map Java 62
[lint] [lint]. Longest Words.java Easy [Hash Table, Lint, String] Java 63
[lint] [lint]. Lowest Common Ancestor II.java Easy [Hash Table, Lint, Tree] Java 64
N/A Line Reflection.java Medium [Hash Table, Math] O(n) O(n) Java 65
N/A Encode and Decode TinyURL.java Medium [Hash Table, Math] Java 66
N/A Fraction to Recurring Decimal.java Medium [Hash Table, Math] Java 67
204 204. Count Primes.java Easy [Hash Table, Math] Java 68
202 202. Happy Number.java Easy [Hash Table, Math] O(m), m iterations O(m), m number in set Java 69
739 739. Daily Temperatures.java Medium [Hash Table, Monotonous Stack, Stack] O(n) O(n) Java 70
N/A Maximum Size Subarray Sum Equals k.java Medium [Hash Table, PreSum, Subarray] O(n) O(n) Java 71
76 76. Minimum Window Substring.java Hard [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 72
159 159. Longest Substring with At Most Two Distinct Characters.java Medium [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 73
438 438. Find All Anagrams in a String.java Medium [Hash Table, Sliding Window, Two Pointers] O(n) O(1) Java 74
632 632. Smallest Range Covering Elements from K Lists.java Hard [Hash Table, Sliding Window, Two Pointers] O(nlogn), n = total elements O(n) to store sorted list Java 75
242 242. Valid Anagram.java Easy [Hash Table, Sort] O(n) O(1), unique chars Java 76
496 496. Next Greater Element I.java Easy [Hash Table, Stack] O(n) O(n) Java 77
94 94. Binary Tree Inorder Traversal.java Easy [Hash Table, Stack, Tree] O(n) O(logn) Java 78
N/A Group Shifted Strings.java Medium [Hash Table, String] Java 79
387 387. First Unique Character in a String.java Easy [Hash Table, String] O(n) O(256) = O(1) Java 80
49 49. Group Anagrams.java Medium [Hash Table, String] O(nk) O(nk) Java 81
N/A Palindrome Pairs.java Hard [Hash Table, String, Trie] Java 82
N/A Longest Substring Without Repeating Characters.java Medium [Hash Table, String, Two Pointers] Java 83
720 720. Longest Word in Dictionary.java Easy [Hash Table, Trie] O(nlogn) O(n) Java 84
1213 1213. Intersection of Three Sorted Arrays.java Easy [Hash Table, Two Pointers] O(m + n + h) two pointers approach O(1) Java 85

String (78)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Word Ladder II.java Hard [Array, BFS, Backtracking, DFS, Hash Table, String] Java 0
[lint] [lint]. Unique Characters.java Easy [Array, Lint, String] Java 1
1170 1170. Compare Strings by Frequency of the Smallest Character.java Easy [Array, String] O(m + n) O(m + n) Java 2
N/A Expression Add Operators.java Hard [Backtracking, DFS, Divide and Conquer, String] O(4^n) O(4^n) Java 3
22 22. Generate Parentheses.java Medium [Backtracking, DFS, Sequence DFS, String] O(2^n) O(2^n) Java 4
N/A Restore IP Addresses.java Medium [Backtracking, DFS, String] Java 5
N/A Wildcard Matching.java Hard [Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String] Java 6
10 10. Regular Expression Matching.java Hard [Backtracking, DP, Double Sequence DP, Sequence DP, String] Java 7
N/A Letter Combinations of a Phone Number.java Medium [Backtracking, String] Java 8
686 686. Repeated String Match.java Easy [Basic Implementation, Edge Case, String] Java 9
N/A Next Closest Time.java Medium [Basic Implementation, Enumeration, String] Java 10
415 415. Add Strings.java Easy [Basic Implementation, Math, String] O(n) O(n) Java 11
12 12. Integer to Roman.java Medium [Basic Implementation, Math, String] O(n) O(n) Java 12
N/A Count and Say.java Easy [Basic Implementation, String] Java 13
788 788. Rotated Digits.java Easy [Basic Implementation, String] O(n) O(n) Java 14
408 408. Valid Word Abbreviation.java Easy [Basic Implementation, String] Java 15
1108 1108. Defanging an IP Address.java Easy [Basic Implementation, String] Java 16
383 383. Ransom Note.java Easy [Basic Implementation, String] Java 17
824 824. Goat Latin.java Easy [Basic Implementation, String] O(n) O(1) Java 18
443 443. String Compression.java Easy [Basic Implementation, String] Java 19
893 893. Groups of Special-Equivalent Strings.java Easy [Basic Implementation, String] Java 20
N/A Binary Representation.java Hard [Bit Manipulation, String] Java 21
N/A Longest Valid Parentheses.java Hard [Coordinate DP, Stack, String] Java 22
1216 1216. Valid Palindrome III.java Hard [DFS, DP, Memoization, String] O(n^2) O(n^2) Java 23
1106 1106. Parsing A Boolean Expression.java Hard [DFS, Stack, String] Java 24
N/A Longest Common Substring.java Medium [DP, Double Sequence DP, Sequence DP, String] Java 25
72 72. Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, String] O(MN) Java 26
727 727. Minimum Window Subsequence.java Hard [DP, Hash Table, Sliding Window, String, Two Pointers] O(n^2) O(1) Java 27
N/A Scramble String.java Hard [DP, Interval DP, String] Java 28
91 91. Decode Ways.java Medium [DP, Partition DP, String] O(n) O(n) Java 29
N/A Palindromic Substrings.java Medium [DP, String] Java 30
N/A Distinct Subsequences.java Hard [DP, String] Java 31
N/A Interleaving String.java Hard [DP, String] Java 32
5 5. Longest Palindromic Substring.java Medium [DP, String] O(n^2) O(n^2) Java 33
273 273. Integer to English Words.java Hard [Enumeration, Math, String] O(n) O(1) Java 34
65 65. Valid Number.java Hard [Enumeration, Math, String] O(n) O(1) Java 35
158 158. Read N Characters Given Read4 II - Call multiple times.java Hard [Enumeration, String] O(n) O(n) Java 36
68 68. Text Justification.java Hard [Enumeration, String] O(n) go over words O(maxLength) buffer list Java 37
157 157. Read N Characters Given Read4.java Easy [Enumeration, String] Java 38
767 767. Reorganize String.java Medium [Greedy, Hash Table, Heap, Sort, String] O(m), m = # of unique letters O(nLogm), n = length Java 39
340 340. Longest Substring with At Most K Distinct Characters.java Hard [Hash Table, LinkedHashMap, Sliding Window, String, Two Pointers] O(n) O(k) Java 40
[lint] [lint]. Longest Words.java Easy [Hash Table, Lint, String] Java 41
76 76. Minimum Window Substring.java Hard [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 42
159 159. Longest Substring with At Most Two Distinct Characters.java Medium [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 43
N/A Group Shifted Strings.java Medium [Hash Table, String] Java 44
387 387. First Unique Character in a String.java Easy [Hash Table, String] O(n) O(256) = O(1) Java 45
49 49. Group Anagrams.java Medium [Hash Table, String] O(nk) O(nk) Java 46
N/A Palindrome Pairs.java Hard [Hash Table, String, Trie] Java 47
N/A Longest Substring Without Repeating Characters.java Medium [Hash Table, String, Two Pointers] Java 48
N/A Shortest Palindrome.java Hard [KMP, String] Java 49
[lint] [lint]. Compare Strings.java Easy [Lint, String] Java 50
N/A Orderly Queue.java Hard [Math, String] Java 51
43 43. Multiply Strings.java Medium [Math, String] O(mn) O(mn) Java 52
8 8. String to Integer (atoi).java Medium [Math, String] O(n) O(n) Java 53
13 13. Roman to Integer.java Easy [Math, String] O(n) O(1) Java 54
67 67. Add Binary.java Easy [Math, String, Two Pointers] Java 55
N/A Sort Letters by Case.java Medium [Partition, Sort, String, Two Pointers] Java 56
1249 1249. Minimum Remove to Make Valid Parentheses.java Medium [Stack, String] O(n) O(n) Java 57
20 20. Valid Parentheses.java Easy [Stack, String] O(n) O(n) Java 58
71 71. Simplify Path.java Medium [Stack, String] O(n) O(n) Java 59
N/A Compare Version Numbers.java Medium [String] Java 60
N/A Space Replacement.java Medium [String] Java 61
N/A Reverse Words in a String II.java Medium [String] Java 62
N/A One Edit Distance.java Medium [String] Java 63
N/A Encode and Decode Strings.java Medium [String] Java 64
N/A [HackerRank]. Change to Anagram.java Easy [String] Java 65
293 293. Flip Game.java Easy [String] Java 66
58 58. Length of Last Word.java Easy [String] Java 67
151 151. Reverse Words in a String.java Medium [String] O(n) Java 68
557 557. Reverse Words in a String III.java Easy [String] Java 69
680 680. Valid Palindrome II.java Easy [String] Java 70
14 14. Longest Common Prefix.java Easy [String] Java 71
796 796. Rotate String.java Easy [String] Java 72
1041 1041. Robot Bounded In Circle.java Easy [String] Java 73
N/A Reverse String.java Easy [String, Two Pointers] Java 74
345 345. Reverse Vowels of a String.java Easy [String, Two Pointers] Java 75
28 28. Implement strStr().java Easy [String, Two Pointers] Java 76
125 125. Valid Palindrome.java Easy [String, Two Pointers] Java 77

Tree (69)

Leetcode# Problem Level Tags Time Space Language Sequence
105 105. Construct Binary Tree from Preorder and Inorder Traversal.java Medium [Array, DFS, Divide and Conquer, Hash Table, Tree] O(n) O(n) Java 0
N/A Construct Binary Tree from Inorder and Postorder Traversal.java Medium [Array, DFS, Divide and Conquer, Tree] Java 1
987 987. Vertical Order Traversal of a Binary Tree.java Medium [BFS, Binary Tree, DFS, Hash Table, Tree] Java 2
297 297. Serialize and Deserialize Binary Tree.java Hard [BFS, DFS, Deque, Design, Divide and Conquer, Tree] O(n) O(n) Java 3
N/A Redundant Connection.java Medium [BFS, DFS, Graph, Tree, Union Find] Java 4
314 314. Binary Tree Vertical Order Traversal.java Medium [BFS, DFS, Hash Table, Tree] O(n) O(n) Java 5
144 144. Binary Tree Preorder Traversal.java Medium [BFS, DFS, Stack, Tree] O(n) O(n) Java 6
N/A Invert Binary Tree.java Easy [BFS, DFS, Tree] Java 7
102 102. Binary Tree Level Order Traversal.java Medium [BFS, DFS, Tree] O(n) O(n) Java 8
111 111. Minimum Depth of Binary Tree.java Easy [BFS, DFS, Tree] O(n) O(n) Java 9
199 199. Binary Tree Right Side View.java Medium [BFS, DFS, Tree] O(n) O(n) Java 10
515 515. Find Largest Value in Each Tree Row.java Medium [BFS, DFS, Tree] O(n) O(n) Java 11
100 100. Same Tree.java Easy [BFS, DFS, Tree] O(n) O(logn) Java 12
1123 1123. Lowest Common Ancestor of Deepest Leaves.java Medium [BFS, DFS, Tree] O(n) O(n) Java 13
101 101. Symmetric Tree.java Easy [BFS, DFS, Tree] O(n) O(n) Java 14
103 103. Binary Tree Zigzag Level Order Traversal.java Medium [BFS, Stack, Tree] O(n) O(n) Java 15
N/A Binary Tree Level Order Traversal II.java Medium [BFS, Tree] Java 16
N/A Complete Binary Tree.java Easy [BFS, Tree] Java 17
429 429. N-ary Tree Level Order Traversal.java Medium [BFS, Tree] O(n) O(n) Java 18
671 671. Second Minimum Node In a Binary Tree.java Easy [BFS, Tree] O(n) O(n) leaf nodes Java 19
270 270. Closest Binary Search Tree Value.java Easy [BST, Binary Search, Tree] O(logn) O(1) Java 20
426 426. Convert Binary Search Tree to Sorted Doubly Linked List.java Medium [BST, DFS, Divide and Conquer, Linked List, Tree] O(n) O(1) Java 21
98 98. Validate Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Tree] O(n) O(logn) Java 22
N/A Kth Smallest Element in a BST.java Medium [BST, DFS, Stack, Tree] Java 23
N/A Recover Binary Search Tree.java Hard [BST, DFS, Tree] Java 24
235 235. Lowest Common Ancestor of a Binary Search Tree.java Easy [BST, DFS, Tree] O(logn) O(logn) Java 25
N/A Unique Binary Search Tree II.java Medium [BST, DP, Divide and Conquer, Tree] Java 26
N/A Unique Binary Search Tree.java Medium [BST, DP, Tree] Java 27
173 173. Binary Search Tree Iterator.java Medium [BST, Design, Stack, Tree] O(1) average O(h) Java 28
938 938. Range Sum of BST.java Easy [BST, Recursion, Tree] Java 29
N/A Inorder Successor in BST.java Medium [BST, Tree] Java 30
N/A Trim a Binary Search Tree.java Easy [BST, Tree] Java 31
N/A Path Sum II.java Easy [Backtracking, DFS, Tree] Java 32
222 222. Count Complete Tree Nodes.java Medium [Binary Search, DFS, Tree] O(n) O(h) Java 33
N/A House Robber III.java Medium [DFS, DP, Status DP, Tree] Java 34
124 124. Binary Tree Maximum Path Sum.java Hard [DFS, DP, Tree, Tree DP] O(n) O(logn) Java 35
N/A Binary Tree Longest Consecutive Sequence II.java Medium [DFS, Divide and Conquer, Double Recursive, Tree] Java 36
N/A Subtree of Another Tree.java Easy [DFS, Divide and Conquer, Tree] Java 37
N/A Convert Sorted Array to Binary Search Tree.java Easy [DFS, Divide and Conquer, Tree] Java 38
N/A Populating Next Right Pointers in Each Node.java Medium [DFS, Divide and Conquer, Tree] Java 39
N/A Smallest Subtree with all the Deepest Nodes.java Medium [DFS, Divide and Conquer, Tree] O(n) O(n) Java 40
N/A Binary Tree Longest Consecutive Sequence.java Medium [DFS, Divide and Conquer, Tree] Java 41
1110 1110. Delete Nodes And Return Forest.java Medium [DFS, Divide and Conquer, Tree] O(n) O(logn) Java 42
N/A Path Sum III.java Easy [DFS, Double Recursive, Tree] Java 43
N/A Redundant Connection II.java Hard [DFS, Graph, Tree, Union Find] Java 44
N/A Path Sum IV.java Medium [DFS, Hash Table, Tree] Java 45
N/A Binary Tree Maximum Path Sum II.java Medium [DFS, Tree] Java 46
N/A Subtree.java Easy [DFS, Tree] Java 47
N/A Tweaked Identical Binary Tree.java Easy [DFS, Tree] Java 48
N/A Merge Two Binary Trees.java Easy [DFS, Tree] Java 49
N/A Populating Next Right Pointers in Each Node II.java Medium [DFS, Tree] O(n) O(1) Java 50
236 236. Lowest Common Ancestor of a Binary Tree.java Medium [DFS, Tree] O(n) O(n) Java 51
1008 1008. Construct Binary Search Tree from Preorder Traversal.java Medium [DFS, Tree] O(n) O(n) Java 52
104 104. Maximum Depth of Binary Tree.java Easy [DFS, Tree] Java 53
110 110. Balanced Binary Tree.java Easy [DFS, Tree] Java 54
112 112. Path Sum.java Easy [DFS, Tree] Java 55
1026 1026. Maximum Difference Between Node and Ancestor.java Medium [DFS, Tree] O(n) O(logn) Java 56
366 366. Find Leaves of Binary Tree.java Medium [DFS, Tree] O(n) O(h) Java 57
156 156. Binary Tree Upside Down.java Medium [DFS, Tree] O(n) O(h) Java 58
[lint] [lint]. Lowest Common Ancestor II.java Easy [Hash Table, Lint, Tree] Java 59
94 94. Binary Tree Inorder Traversal.java Easy [Hash Table, Stack, Tree] O(n) O(logn) Java 60
N/A Convert Binary Search Tree to Sorted Doubly Linked List (extra space).java Medium [Linked List, Stack, Tree] O(n) O(n) Java 61
N/A Maximum Binary Tree.java Medium [Stack, Tree] Java 62
272 272. Closest Binary Search Tree Value II.java Hard [Stack, Tree] O(n) O(n) Java 63
145 145. Binary Tree Postorder Traversal.java Medium [Stack, Tree, Two Stacks] O(n) O(n) Java 64
N/A Two Sum IV - Input is a BST.java Easy [Tree] Java 65
543 543. Diameter of Binary Tree.java Easy [Tree] O(n) when non-balanced O(n) when non-balanced Java 66
427 427. Construct Quad Tree.java Medium [Tree] O(n^2) O(n^2) Java 67
449 449. Serialize and Deserialize BST.java Medium [Tree] O(n) O(��n) Java 68

Two Pointers (57)

Leetcode# Problem Level Tags Time Space Language Sequence
849 849. Maximize Distance to Closest Person.java Easy [Array, Basic Implementation, Two Pointers] O(n) O(1) Java 0
287 287. Find the Duplicate Number.java Medium [Array, Binary Search, Binary Search on Value, Cycle Detection, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 1
[lint] [lint]. 2 Sum II.java Medium [Array, Binary Search, Lint, Two Pointers] Java 2
N/A Minimum Size Subarray Sum.java Medium [Array, Binary Search, Subarray, Two Pointers] O(n) O(1) Java 3
N/A Subarray Sum II.java Hard [Array, Binary Search, Two Pointers] Java 4
N/A Two Sum II - Input array is sorted.java Medium [Array, Binary Search, Two Pointers] Java 5
244 244. Shortest Word Distance II.java Medium [Array, Design, Hash Table, Two Pointers] O(n) to build map, O(a + b) to query O(n) Java 6
245 245. Shortest Word Distance III.java Medium [Array, Design, Hash Table, Two Pointers] O(n) O(1) Java 7
N/A [tool] Quick Select - Median.java Easy [Array, Lint, Quick Select, Quick Sort, Two Pointers] O(n) O(logN) Java 8
[lint] [lint]. 3 Sum Closest.java Medium [Array, Lint, Two Pointers] Java 9
N/A Sort Colors.java Medium [Array, Partition, Quick Sort, Sort, Two Pointers] Java 10
N/A Partition Array.java Medium [Array, Quick Sort, Sort, Two Pointers] Java 11
N/A The Smallest Difference.java Medium [Array, Sort, Two Pointers] Java 12
259 259. 3Sum Smaller.java Medium [Array, Sort, Two Pointers] Java 13
15 15. 3Sum.java Medium [Array, Sort, Two Pointers] O(n^2) Java 14
42 42. Trapping Rain Water.java Hard [Array, Stack, Two Pointers] O(n) O(1) Java 15
N/A Container With Most Water.java Medium [Array, Two Pointers] Java 16
N/A Partition Array by Odd and Even.java Easy [Array, Two Pointers] Java 17
80 80.Remove Duplicates from Sorted Array II.java Medium [Array, Two Pointers] Java 18
26 26.Remove Duplicates from Sorted Array.java Easy [Array, Two Pointers] Java 19
977 977. Squares of a Sorted Array.java Easy [Array, Two Pointers] O(n) O(n) Java 20
88 88. Merge Sorted Array.java Easy [Array, Two Pointers] O(n) O(1) Java 21
243 243. Shortest Word Distance.java Easy [Array, Two Pointers] O(n) O(1) Java 22
283 283. Move Zeroes.java Easy [Array, Two Pointers] O(n) O(1) Java 23
611 611. Valid Triangle Number.java Medium [Array, Two Pointers] O(n^2) O(logn), sorting space Java 24
349 349. Intersection of Two Arrays.java Easy [Binary Search, Hash Table, Sort, Two Pointers] O(m + n) O(m + n) Java 25
350 350. Intersection of Two Arrays II.java Easy [Binary Search, Hash Table, Sort, Two Pointers] (n) (n) Java 26
142 142. Linked List Cycle II.java Medium [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 27
141 141. Linked List Cycle.java Easy [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 28
727 727. Minimum Window Subsequence.java Hard [DP, Hash Table, Sliding Window, String, Two Pointers] O(n^2) O(1) Java 29
246 246. Strobogrammatic Number.java Easy [Enumeration, Hash Table, Math, Two Pointers] O(n) O(1) Java 30
340 340. Longest Substring with At Most K Distinct Characters.java Hard [Hash Table, LinkedHashMap, Sliding Window, String, Two Pointers] O(n) O(k) Java 31
76 76. Minimum Window Substring.java Hard [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 32
159 159. Longest Substring with At Most Two Distinct Characters.java Medium [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 33
438 438. Find All Anagrams in a String.java Medium [Hash Table, Sliding Window, Two Pointers] O(n) O(1) Java 34
632 632. Smallest Range Covering Elements from K Lists.java Hard [Hash Table, Sliding Window, Two Pointers] O(nlogn), n = total elements O(n) to store sorted list Java 35
N/A Longest Substring Without Repeating Characters.java Medium [Hash Table, String, Two Pointers] Java 36
1213 1213. Intersection of Three Sorted Arrays.java Easy [Hash Table, Two Pointers] O(m + n + h) two pointers approach O(1) Java 37
N/A Linked List Cycle II.java Medium [Linked List, Math, Two Pointers] Java 38
N/A Rotate List.java Medium [Linked List, Two Pointers] Java 39
N/A Partition List.java Medium [Linked List, Two Pointers] Java 40
19 19. Remove Nth Node From End of List.java Medium [Linked List, Two Pointers] O(n) O(1) Java 41
234 234. Palindrome Linked List.java Easy [Linked List, Two Pointers] O(n) O(1) Java 42
67 67. Add Binary.java Easy [Math, String, Two Pointers] Java 43
360 360. Sort Transformed Array.java Medium [Math, Two Pointers] O(n) O(n) store result Java 44
N/A Sort Colors II.java Medium [Partition, Quick Sort, Sort, Two Pointers] Java 45
N/A Sort Letters by Case.java Medium [Partition, Sort, String, Two Pointers] Java 46
567 567. Permutation in String.java Medium [Sliding Window, Two Pointers] O(m + n) O(1) Java 47
1004 1004. Max Consecutive Ones III.java Medium [Sliding Window, Two Pointers] O(n) O(1) Java 48
N/A Backspace String Compare.java Easy [Stack, Two Pointers] Java 49
844 844. Backspace String Compare.java Easy [Stack, Two Pointers] O(n) O(1) Java 50
N/A Reverse String.java Easy [String, Two Pointers] Java 51
345 345. Reverse Vowels of a String.java Easy [String, Two Pointers] Java 52
28 28. Implement strStr().java Easy [String, Two Pointers] Java 53
125 125. Valid Palindrome.java Easy [String, Two Pointers] Java 54
N/A Interleaving Positive and Negative Numbers.java Medium [Two Pointers] Java 55
986 986. Interval List Intersections.java Medium [Two Pointers] O(n) O(1) Java 56

BFS (54)

Leetcode# Problem Level Tags Time Space Language Sequence
78 78. Subsets.java Medium [Array, BFS, Backtracking, Bit Manipulation, DFS] O(2^n) O(2^n) Java 0
N/A Subsets II.java Medium [Array, BFS, Backtracking, DFS] O(2^n) Java 1
N/A Word Ladder II.java Hard [Array, BFS, Backtracking, DFS, Hash Table, String] Java 2
N/A Word Ladder.java Medium [BFS] Java 3
N/A Shortest Distance from All Buildings.java Hard [BFS] Java 4
N/A Bus Routes.java Hard [BFS] Java 5
1091 1091. Shortest Path in Binary Matrix.java Medium [BFS] O(n^2) Java 6
1197 1197. Minimum Knight Moves.java Medium [BFS] O(8^n) O(8^n) Java 7
254 254. Factor Combinations.java Medium [BFS, Backtracking, DFS] O(x), x is the # of results O(y), y is all ongoing candidates in queue Java 8
269 269. Alien Dictionary.java Hard [BFS, Backtracking, DFS, Graph, Topological Sort] O(n), n = # of graph edges O(n) Java 9
207 207. Course Schedule.java Medium [BFS, Backtracking, DFS, Graph, Topological Sort] O(n) O(n) Java 10
46 46. Permutations.java Medium [BFS, Backtracking, DFS, Permutation] O(n!) O(n!) Java 11
987 987. Vertical Order Traversal of a Binary Tree.java Medium [BFS, Binary Tree, DFS, Hash Table, Tree] Java 12
N/A Walls and Gates.java Medium [BFS, DFS] Java 13
N/A The Maze.java Medium [BFS, DFS] Java 14
N/A Find the Connected Component in the Undirected Graph.java Medium [BFS, DFS] Java 15
301 301. Remove Invalid Parentheses.java Hard [BFS, DFS, DP] Java 16
297 297. Serialize and Deserialize Binary Tree.java Hard [BFS, DFS, Deque, Design, Divide and Conquer, Tree] O(n) O(n) Java 17
785 785. Is Graph Bipartite.java Medium [BFS, DFS, Garph] O(n) O(n) Java 18
1161 1161. Maximum Level Sum of a Binary Tree.java Medium [BFS, DFS, Graph] O(n) visit all nodes O(n) Java 19
133 133. Clone Graph.java Medium [BFS, DFS, Graph] O(n) O(n) Java 20
743 743. Network Delay Time.java Medium [BFS, DFS, Graph, Heap, PQ] O(nlogn) O(n) Java 21
1203 1203. Sort Items by Groups Respecting Dependencies.java Hard [BFS, DFS, Graph, Topological Sort] O(V + E) to traverse the graph, #nodes + #edges O(V + E) Java 22
210 210. Course Schedule II.java Medium [BFS, DFS, Graph, Topological Sort] O(n) O(n) Java 23
N/A Redundant Connection.java Medium [BFS, DFS, Graph, Tree, Union Find] Java 24
N/A Number of Connected Components in an Undirected Graph.java Medium [BFS, DFS, Graph, Union Find] Java 25
261 261. Graph Valid Tree.java Medium [BFS, DFS, Graph, Union Find] Java 26
399 399. Evaluate Division.java Medium [BFS, DFS, Graph, Union Find] Java 27
314 314. Binary Tree Vertical Order Traversal.java Medium [BFS, DFS, Hash Table, Tree] O(n) O(n) Java 28
[tool] [tool]. Topological Sorting.java Medium [BFS, DFS, Lint, Topological Sort] O(V + E) O(V + E) Java 29
N/A Surrounded Regions.java Medium [BFS, DFS, Matrix DFS, Union Find] Java 30
200 200. Number of Islands.java Medium [BFS, DFS, Matrix DFS, Union Find] O(n) O(n) Java 31
339 339. Nested List Weight Sum.java Easy [BFS, DFS, NestedInteger] O(n) O(h), h = levels Java 32
N/A The Maze II.java Medium [BFS, DFS, PriorityQueue] Java 33
N/A The Maze III.java Hard [BFS, DFS, PriorityQueue] Java 34
144 144. Binary Tree Preorder Traversal.java Medium [BFS, DFS, Stack, Tree] O(n) O(n) Java 35
N/A Invert Binary Tree.java Easy [BFS, DFS, Tree] Java 36
102 102. Binary Tree Level Order Traversal.java Medium [BFS, DFS, Tree] O(n) O(n) Java 37
111 111. Minimum Depth of Binary Tree.java Easy [BFS, DFS, Tree] O(n) O(n) Java 38
199 199. Binary Tree Right Side View.java Medium [BFS, DFS, Tree] O(n) O(n) Java 39
515 515. Find Largest Value in Each Tree Row.java Medium [BFS, DFS, Tree] O(n) O(n) Java 40
100 100. Same Tree.java Easy [BFS, DFS, Tree] O(n) O(logn) Java 41
1123 1123. Lowest Common Ancestor of Deepest Leaves.java Medium [BFS, DFS, Tree] O(n) O(n) Java 42
101 101. Symmetric Tree.java Easy [BFS, DFS, Tree] O(n) O(n) Java 43
N/A Perfect Squares.java Medium [BFS, DP, Math, Partition DP] Java 44
N/A Minimum Height Trees.java Medium [BFS, Graph] Java 45
N/A Sliding Puzzle.java Hard [BFS, Graph] Java 46
1306 1306. Jump Game III.java Medium [BFS, Graph] O(n) O(n) Java 47
N/A Trapping Rain Water II.java Hard [BFS, Heap, MinHeap, PriorityQueue] Java 48
103 103. Binary Tree Zigzag Level Order Traversal.java Medium [BFS, Stack, Tree] O(n) O(n) Java 49
N/A Binary Tree Level Order Traversal II.java Medium [BFS, Tree] Java 50
N/A Complete Binary Tree.java Easy [BFS, Tree] Java 51
429 429. N-ary Tree Level Order Traversal.java Medium [BFS, Tree] O(n) O(n) Java 52
671 671. Second Minimum Node In a Binary Tree.java Easy [BFS, Tree] O(n) O(n) leaf nodes Java 53

Math (45)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Missing Number.java Easy [Array, Bit Manipulation, Math] Java 0
149 149. Max Points on a Line.java Hard [Array, Geometry, Hash Table, Math] O(n^2) O() Java 1
N/A Plus One.java Easy [Array, Math] Java 2
N/A Friends Of Appropriate Ages.java Medium [Array, Math] Java 3
N/A Perfect Squares.java Medium [BFS, DP, Math, Partition DP] Java 4
N/A Permutation Sequence.java Medium [Backtracking, Math] Java 5
415 415. Add Strings.java Easy [Basic Implementation, Math, String] O(n) O(n) Java 6
12 12. Integer to Roman.java Medium [Basic Implementation, Math, String] O(n) O(n) Java 7
N/A Pow(x, n).java Medium [Binary Search, Math] Java 8
367 367. Valid Perfect Square.java Easy [Binary Search, Math] O(logN) O(1) Java 9
69 69. Sqrt(x).java Easy [Binary Search, Math] Java 10
N/A Basic Calculator.java Hard [Binary Tree, Expression Tree, Math, Minimum Binary Tree, Stack] Java 11
N/A Power of Two.java Easy [Bit Manipulation, Math] Java 12
319 319. Bulb Switcher.java Medium [Brainteaser, Math] O(1) O(1) Java 13
523 523. Continuous Subarray Sum.java Medium [Coordinate DP, DP, Math, PreSum, Subarray] O(n) O(k) Java 14
N/A Strobogrammatic Number II.java Medium [DFS, Enumeration, Math, Sequence DFS] Java 15
N/A Cracking the Safe.java Hard [DFS, Greedy, Math] Java 16
N/A Ugly Number II.java Medium [DP, Enumeration, Heap, Math, PriorityQueue] O(n) O(n) Java 17
N/A Number Of Corner Rectangles.java Medium [DP, Math] Java 18
509 509. Fibonacci Number.java Easy [DP, Math, Memoization] Java 19
246 246. Strobogrammatic Number.java Easy [Enumeration, Hash Table, Math, Two Pointers] O(n) O(1) Java 20
273 273. Integer to English Words.java Hard [Enumeration, Math, String] O(n) O(1) Java 21
65 65. Valid Number.java Hard [Enumeration, Math, String] O(n) O(1) Java 22
N/A Line Reflection.java Medium [Hash Table, Math] O(n) O(n) Java 23
N/A Encode and Decode TinyURL.java Medium [Hash Table, Math] Java 24
N/A Fraction to Recurring Decimal.java Medium [Hash Table, Math] Java 25
204 204. Count Primes.java Easy [Hash Table, Math] Java 26
202 202. Happy Number.java Easy [Hash Table, Math] O(m), m iterations O(m), m number in set Java 27
2 2. Add Two Numbers.java Medium [Linked List, Math] O(max(m,n)) O(max(m,n)) Java 28
N/A Linked List Cycle II.java Medium [Linked List, Math, Two Pointers] Java 29
N/A Trailing Zeros.java Easy [Math] Java 30
N/A Ugly Number.java Medium [Math] Java 31
N/A Number of Digit One.java Hard [Math] Java 32
N/A Power of Three.java Easy [Math] Java 33
N/A Add Digits.java Easy [Math] Java 34
N/A Excel Sheet Column Number.java Easy [Math] Java 35
7 7. Reverse Integer.java Easy [Math] O(n) O(1) Java 36
168 168. Excel Sheet Column Title.java Easy [Math] O(n) O(1) Java 37
9 9. Palindrome Number.java Easy [Math] Java 38
N/A Orderly Queue.java Hard [Math, String] Java 39
43 43. Multiply Strings.java Medium [Math, String] O(mn) O(mn) Java 40
8 8. String to Integer (atoi).java Medium [Math, String] O(n) O(n) Java 41
13 13. Roman to Integer.java Easy [Math, String] O(n) O(1) Java 42
67 67. Add Binary.java Easy [Math, String, Two Pointers] Java 43
360 360. Sort Transformed Array.java Medium [Math, Two Pointers] O(n) O(n) store result Java 44

Binary Search (45)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Max Sum of Rectangle No Larger Than K.java Hard [Array, BST, Binary Search, DP, Queue, TreeSet] Java 0
N/A Find Minimum in Rotated Sorted Array.java Medium [Array, Binary Search] Java 1
N/A Find Peak Element.java Medium [Array, Binary Search] Java 2
N/A Find Minimum in Rotated Sorted Array II.java Hard [Array, Binary Search] Java 3
N/A Search for a Range.java Medium [Array, Binary Search] Java 4
N/A Search a 2D Matrix.java Medium [Array, Binary Search] Java 5
88 88. Search in Rotated Sorted Array II.java Medium [Array, Binary Search] O(logn), worst O(n) O(1) Java 6
33 33. Search in Rotated Sorted Array.java Medium [Array, Binary Search] O(logn) O(1) Java 7
34 34. Find First and Last Position of Element in Sorted Array.java Medium [Array, Binary Search] O(logn) O(1) Java 8
287 287. Find the Duplicate Number.java Medium [Array, Binary Search, Binary Search on Value, Cycle Detection, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 9
N/A Median of Two Sorted Arrays.java Hard [Array, Binary Search, DFS, Divide and Conquer] Java 10
[lint] [lint]. 2 Sum II.java Medium [Array, Binary Search, Lint, Two Pointers] Java 11
N/A Maximum Average Subarray II.java Review [Array, Binary Search, PreSum] Java 12
N/A Minimum Size Subarray Sum.java Medium [Array, Binary Search, Subarray, Two Pointers] O(n) O(1) Java 13
N/A Subarray Sum II.java Hard [Array, Binary Search, Two Pointers] Java 14
N/A Two Sum II - Input array is sorted.java Medium [Array, Binary Search, Two Pointers] Java 15
315 315. Count of Smaller Numbers After Self.java Hard [BST, Binary Indexed Tree, Binary Search, Divide and Conquer, Segment Tree] O(nlogn) O(n) Java 16
270 270. Closest Binary Search Tree Value.java Easy [BST, Binary Search, Tree] O(logn) O(1) Java 17
N/A Closest Number in Sorted Array.java Easy [Binary Search] Java 18
N/A Classical Binary Search.java Easy [Binary Search] Java 19
N/A Wood Cut.java Medium [Binary Search] Java 20
N/A Guess Number Higher or Lower.java Easy [Binary Search] Java 21
N/A Last Position of Target.java Easy [Binary Search] Java 22
275 275. H-Index II.java Medium [Binary Search] O(logN) O(1) extra Java 23
1060 1060. Missing Element in Sorted Array.java Medium [Binary Search] O(logn) O(1) Java 24
875 875. Koko Eating Bananas.java Medium [Binary Search] O(n*logM) O(1) Java 25
852 852. Peak Index in a Mountain Array.java Easy [Binary Search] O(logn) O(1) Java 26
278 278. First Bad Version.java Easy [Binary Search] O(logN) O(1) Java 27
N/A Russian Doll Envelopes.java Hard [Binary Search, Coordinate DP, DP] Java 28
N/A Longest Increasing Subsequence.java Medium [Binary Search, Coordinate DP, DP, Memoization] O(n^2) dp, O(nLogN) binary search O(n) Java 29
N/A Find Peak Element II.java Hard [Binary Search, DFS, Divide and Conquer] Java 30
222 222. Count Complete Tree Nodes.java Medium [Binary Search, DFS, Tree] O(n) O(h) Java 31
N/A Copy Books.java Hard [Binary Search, DP, Partition DP] Java 32
N/A Search a 2D Matrix II.java Medium [Binary Search, Divide and Conquer] Java 33
N/A Interval Minimum Number.java Medium [Binary Search, Divide and Conquer, Lint, Segment Tree] Java 34
349 349. Intersection of Two Arrays.java Easy [Binary Search, Hash Table, Sort, Two Pointers] O(m + n) O(m + n) Java 35
350 350. Intersection of Two Arrays II.java Easy [Binary Search, Hash Table, Sort, Two Pointers] (n) (n) Java 36
981 981. Time Based Key-Value Store.java Medium [Binary Search, Hash Table, TreeMap] set O(1), get(logn) O(n) Java 37
N/A Kth Smallest Element in a Sorted Matrix.java Medium [Binary Search, Heap] O(n + klogn) O(n) Java 38
N/A Count of Smaller Number.java Medium [Binary Search, Lint, Segment Tree] Java 39
N/A Interval Sum.java Medium [Binary Search, Lint, Segment Tree] Java 40
N/A Interval Sum II.java Hard [Binary Search, Lint, Segment Tree] Java 41
N/A Pow(x, n).java Medium [Binary Search, Math] Java 42
367 367. Valid Perfect Square.java Easy [Binary Search, Math] O(logN) O(1) Java 43
69 69. Sqrt(x).java Easy [Binary Search, Math] Java 44

Stack (38)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Maximal Rectangle.java Hard [Array, DP, Hash Table, Stack] Java 0
N/A Largest Rectangle in Histogram.java Hard [Array, Monotonous Stack, Stack] Java 1
42 42. Trapping Rain Water.java Hard [Array, Stack, Two Pointers] O(n) O(1) Java 2
144 144. Binary Tree Preorder Traversal.java Medium [BFS, DFS, Stack, Tree] O(n) O(n) Java 3
103 103. Binary Tree Zigzag Level Order Traversal.java Medium [BFS, Stack, Tree] O(n) O(n) Java 4
N/A Kth Smallest Element in a BST.java Medium [BST, DFS, Stack, Tree] Java 5
173 173. Binary Search Tree Iterator.java Medium [BST, Design, Stack, Tree] O(1) average O(h) Java 6
N/A Expression Evaluation.java Hard [Binary Tree, DFS, Expression Tree, Minimum Binary Tree, Stack] Java 7
N/A Convert Expression to Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 8
N/A Convert Expression to Reverse Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 9
N/A Basic Calculator.java Hard [Binary Tree, Expression Tree, Math, Minimum Binary Tree, Stack] Java 10
N/A Expression Tree Build.java Hard [Binary Tree, Expression Tree, Minimum Binary Tree, Stack] Java 11
N/A Longest Valid Parentheses.java Hard [Coordinate DP, Stack, String] Java 12
N/A Decode String.java Medium [DFS, Divide and Conquer, Stack] Java 13
1106 1106. Parsing A Boolean Expression.java Hard [DFS, Stack, String] Java 14
716 716. Max Stack.java Medium [Design, Doubly Linked List, Stack, TreeMap] avg O(1), [O(logN) peekMax(), TreeMap]; [O(n) popMax(), TwoStack] O(n) Java 15
341 341. Flatten Nested List Iterator.java Medium [Design, NestedInteger, Stack] O(n) O(n) Java 16
N/A Implement Stack using Queues.java Easy [Design, Stack] Java 17
N/A Min Stack.java Easy [Design, Stack] Java 18
N/A Implement Queue using Stacks.java Easy [Design, Stack] Java 19
N/A Remove Duplicate Letters.java Hard [Greedy, Hash Table, Stack] Java 20
402 402. Remove K Digits.java Medium [Greedy, Monotonous Stack, Stack] O(n) O(n) Java 21
739 739. Daily Temperatures.java Medium [Hash Table, Monotonous Stack, Stack] O(n) O(n) Java 22
496 496. Next Greater Element I.java Easy [Hash Table, Stack] O(n) O(n) Java 23
94 94. Binary Tree Inorder Traversal.java Easy [Hash Table, Stack, Tree] O(n) O(logn) Java 24
N/A Convert Binary Search Tree to Sorted Doubly Linked List (extra space).java Medium [Linked List, Stack, Tree] O(n) O(n) Java 25
N/A Implement Stack.java Easy [Stack] Java 26
N/A Evaluate Reverse Polish Notation.java Medium [Stack] O(n) O(n) Java 27
1021 1021. Remove Outermost Parentheses.java Easy [Stack] Java 28
636 636. Exclusive Time of Functions.java Medium [Stack] O(n) O(n) Java 29
1249 1249. Minimum Remove to Make Valid Parentheses.java Medium [Stack, String] O(n) O(n) Java 30
20 20. Valid Parentheses.java Easy [Stack, String] O(n) O(n) Java 31
71 71. Simplify Path.java Medium [Stack, String] O(n) O(n) Java 32
N/A Maximum Binary Tree.java Medium [Stack, Tree] Java 33
272 272. Closest Binary Search Tree Value II.java Hard [Stack, Tree] O(n) O(n) Java 34
145 145. Binary Tree Postorder Traversal.java Medium [Stack, Tree, Two Stacks] O(n) O(n) Java 35
N/A Backspace String Compare.java Easy [Stack, Two Pointers] Java 36
844 844. Backspace String Compare.java Easy [Stack, Two Pointers] O(n) O(1) Java 37

Divide and Conquer (38)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Median of Two Sorted Arrays.java Hard [Array, Binary Search, DFS, Divide and Conquer] Java 0
169 169. Majority Element.java Easy [Array, Bit Manipulation, Divide and Conquer, Moore Voting, Sort] O(n) O(1) Java 1
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 2
105 105. Construct Binary Tree from Preorder and Inorder Traversal.java Medium [Array, DFS, Divide and Conquer, Hash Table, Tree] O(n) O(n) Java 3
N/A Construct Binary Tree from Inorder and Postorder Traversal.java Medium [Array, DFS, Divide and Conquer, Tree] Java 4
297 297. Serialize and Deserialize Binary Tree.java Hard [BFS, DFS, Deque, Design, Divide and Conquer, Tree] O(n) O(n) Java 5
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 6
327 327. Count of Range Sum.java Hard [BIT, Divide and Conquer, Merge Sort, PreSum, Segment Tree] O(nlogn) O(n) Java 7
315 315. Count of Smaller Numbers After Self.java Hard [BST, Binary Indexed Tree, Binary Search, Divide and Conquer, Segment Tree] O(nlogn) O(n) Java 8
493 493. Reverse Pairs.java Medium [BST, Binary Indexed Tree, Divide and Conquer, Merge Sort, Segment Tree] Java 9
N/A Convert Sorted List to Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Linked List] Java 10
426 426. Convert Binary Search Tree to Sorted Doubly Linked List.java Medium [BST, DFS, Divide and Conquer, Linked List, Tree] O(n) O(1) Java 11
98 98. Validate Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Tree] O(n) O(logn) Java 12
N/A Unique Binary Search Tree II.java Medium [BST, DP, Divide and Conquer, Tree] Java 13
N/A Expression Add Operators.java Hard [Backtracking, DFS, Divide and Conquer, String] O(4^n) O(4^n) Java 14
N/A Find Peak Element II.java Hard [Binary Search, DFS, Divide and Conquer] Java 15
N/A Search a 2D Matrix II.java Medium [Binary Search, Divide and Conquer] Java 16
N/A Interval Minimum Number.java Medium [Binary Search, Divide and Conquer, Lint, Segment Tree] Java 17
N/A Segment Tree Modify.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 18
N/A Segment Tree Query II.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 19
[lint] [lint]. Segment Tree Query.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 20
[lint] [lint]. Segment Tree Build II.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 21
[lint] [lint]. Segment Tree Build.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 22
N/A Fast Power.java Medium [DFS, Divide and Conquer] Java 23
N/A Binary Tree Longest Consecutive Sequence II.java Medium [DFS, Divide and Conquer, Double Recursive, Tree] Java 24
N/A Decode String.java Medium [DFS, Divide and Conquer, Stack] Java 25
N/A Subtree of Another Tree.java Easy [DFS, Divide and Conquer, Tree] Java 26
N/A Convert Sorted Array to Binary Search Tree.java Easy [DFS, Divide and Conquer, Tree] Java 27
N/A Populating Next Right Pointers in Each Node.java Medium [DFS, Divide and Conquer, Tree] Java 28
N/A Smallest Subtree with all the Deepest Nodes.java Medium [DFS, Divide and Conquer, Tree] O(n) O(n) Java 29
N/A Binary Tree Longest Consecutive Sequence.java Medium [DFS, Divide and Conquer, Tree] Java 30
1110 1110. Delete Nodes And Return Forest.java Medium [DFS, Divide and Conquer, Tree] O(n) O(logn) Java 31
N/A Burst Balloons.java Hard [DP, Divide and Conquer, Interval DP, Memoization] Java 32
23 23. Merge k Sorted Lists.java Medium [Divide and Conquer, Heap, Linked List, Merge Sort, PriorityQueue] O(nlogk) O(logk) Java 33
215 215. Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Select, Quick Sort] O(nlogk) O(k) Java 34
N/A Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Sort] Java 35
973 973. K Closest Points to Origin.java Medium [Divide and Conquer, Heap, Sort] O(klogk) O(k) Java 36
N/A Sort List.java Medium [Divide and Conquer, Linked List, Merge Sort, Sort] Java 37

Backtracking (35)

Leetcode# Problem Level Tags Time Space Language Sequence
78 78. Subsets.java Medium [Array, BFS, Backtracking, Bit Manipulation, DFS] O(2^n) O(2^n) Java 0
N/A Subsets II.java Medium [Array, BFS, Backtracking, DFS] O(2^n) Java 1
N/A Word Ladder II.java Hard [Array, BFS, Backtracking, DFS, Hash Table, String] Java 2
N/A Combination Sum III.java Medium [Array, Backtracking, Combination, DFS] Java 3
39 39. Combination Sum.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(k) stack depth, if not counting result size Java 4
40 40. Combination Sum II.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(n) stack depth, if not counting result size Java 5
N/A Word Search.java Medium [Array, Backtracking, DFS] Java 6
254 254. Factor Combinations.java Medium [BFS, Backtracking, DFS] O(x), x is the # of results O(y), y is all ongoing candidates in queue Java 7
269 269. Alien Dictionary.java Hard [BFS, Backtracking, DFS, Graph, Topological Sort] O(n), n = # of graph edges O(n) Java 8
207 207. Course Schedule.java Medium [BFS, Backtracking, DFS, Graph, Topological Sort] O(n) O(n) Java 9
46 46. Permutations.java Medium [BFS, Backtracking, DFS, Permutation] O(n!) O(n!) Java 10
N/A Gray Code.java Medium [Backtracking] Java 11
51 51. N-Queens.java Hard [Backtracking] O(n!) O(n^2) Java 12
52 52. N-Queens II.java Hard [Backtracking] O(n!) O(n) Java 13
257 257. Binary Tree Paths.java Easy [Backtracking, Binary Tree, DFS] O(n) O(nlogn) Java 14
N/A Combinations.java Medium [Backtracking, Combination, DFS] Java 15
N/A Robot Room Cleaner.java Hard [Backtracking, DFS] Java 16
131 131. Palindrome Partitioning.java Medium [Backtracking, DFS] O(2^n) O(n^2) Java 17
1219 1219. Path with Maximum Gold.java Medium [Backtracking, DFS] O(n^2) O(n) recursive depth Java 18
47 47. Permutations II.java Medium [Backtracking, DFS] Java 19
N/A Flip Game II.java Medium [Backtracking, DFS, DP] Java 20
140 140. Word Break II.java Hard [Backtracking, DFS, DP, Hash Table, Memoization] O(n!) O(n!) Java 21
N/A Expression Add Operators.java Hard [Backtracking, DFS, Divide and Conquer, String] O(4^n) O(4^n) Java 22
332 332. Reconstruct Itinerary.java Medium [Backtracking, DFS, Graph] O(n^n) O(�m) Java 23
22 22. Generate Parentheses.java Medium [Backtracking, DFS, Sequence DFS, String] O(2^n) O(2^n) Java 24
N/A Restore IP Addresses.java Medium [Backtracking, DFS, String] Java 25
N/A Path Sum II.java Easy [Backtracking, DFS, Tree] Java 26
N/A Word Search II.java Hard [Backtracking, DFS, Trie] Java 27
N/A Wildcard Matching.java Hard [Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String] Java 28
10 10. Regular Expression Matching.java Hard [Backtracking, DP, Double Sequence DP, Sequence DP, String] Java 29
211 211. Add and Search Word - Data structure design.java Medium [Backtracking, Design, Trie] O(n) to search and to add word < O(mn), depends on the input. m = # of words Java 30
N/A Permutation Sequence.java Medium [Backtracking, Math] Java 31
N/A Palindrome Permutation II.java Medium [Backtracking, Permutation] Java 32
N/A Letter Combinations of a Phone Number.java Medium [Backtracking, String] Java 33
N/A Word Squares.java Hard [Backtracking, Trie] Java 34

Linked List (34)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Convert Sorted List to Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Linked List] Java 0
426 426. Convert Binary Search Tree to Sorted Doubly Linked List.java Medium [BST, DFS, Divide and Conquer, Linked List, Tree] O(n) O(1) Java 1
142 142. Linked List Cycle II.java Medium [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 2
141 141. Linked List Cycle.java Easy [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 3
430 430. Flatten a Multilevel Doubly Linked List.java Medium [DFS, Linked List] O(n) O(1) Java 4
146 146. LRU Cache.java Medium [Design, Doubly Linked List, Hash Table, Linked List] O(1) O(1) Java 5
23 23. Merge k Sorted Lists.java Medium [Divide and Conquer, Heap, Linked List, Merge Sort, PriorityQueue] O(nlogk) O(logk) Java 6
N/A Sort List.java Medium [Divide and Conquer, Linked List, Merge Sort, Sort] Java 7
N/A Majority Number III.java Medium [Hash Table, Linked List] Java 8
138 138. Copy List with Random Pointer.java Medium [Hash Table, Linked List] O(n) O(n) Java 9
N/A Two Lists Sum.java Medium [Linked List] Java 10
N/A Swap Nodes in Pairs.java Medium [Linked List] Java 11
N/A Reverse Linked List II .java Medium [Linked List] Java 12
N/A Reorder List.java Medium [Linked List] Java 13
N/A Remove Duplicates from Unsorted List.java Medium [Linked List] Java 14
N/A Remove Duplicates from Sorted List II.java Medium [Linked List] Java 15
N/A Add Two Numbers II.java Medium [Linked List] Java 16
21 21. Merge Two Sorted Lists.java Easy [Linked List] O(n) O(1) Java 17
237 237. Delete Node in a Linked List.java Easy [Linked List] Java 18
83 83. Remove Duplicates from Sorted List.java Easy [Linked List] Java 19
203 203. Remove Linked List Elements.java Easy [Linked List] Java 20
206 206. Reverse Linked List.java Easy [Linked List] Java 21
369 369. Plus One Linked List.java Medium [Linked List] O(n) O(1) Java 22
876 876. Middle of Linked List.java Easy [Linked List] Java 23
160 160. Intersection of Two Linked Lists.java Easy [Linked List] Java 24
[lint] [lint]. Nth to Last Node in List.java Easy [Linked List, Lint] Java 25
2 2. Add Two Numbers.java Medium [Linked List, Math] O(max(m,n)) O(max(m,n)) Java 26
N/A Linked List Cycle II.java Medium [Linked List, Math, Two Pointers] Java 27
N/A Insertion Sort List.java Medium [Linked List, Sort] Java 28
N/A Convert Binary Search Tree to Sorted Doubly Linked List (extra space).java Medium [Linked List, Stack, Tree] O(n) O(n) Java 29
N/A Rotate List.java Medium [Linked List, Two Pointers] Java 30
N/A Partition List.java Medium [Linked List, Two Pointers] Java 31
19 19. Remove Nth Node From End of List.java Medium [Linked List, Two Pointers] O(n) O(1) Java 32
234 234. Palindrome Linked List.java Easy [Linked List, Two Pointers] O(n) O(1) Java 33

Sort (31)

Leetcode# Problem Level Tags Time Space Language Sequence
169 169. Majority Element.java Easy [Array, Bit Manipulation, Divide and Conquer, Moore Voting, Sort] O(n) O(1) Java 0
N/A Number of Airplane in the sky.java Medium [Array, Interval, PriorityQueue, Sort, Sweep Line] Java 1
N/A Sort Colors.java Medium [Array, Partition, Quick Sort, Sort, Two Pointers] Java 2
56 56. Merge Intervals.java Medium [Array, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 3
57 57. Insert Interval.java Hard [Array, PriorityQueue, Sort, Sweep Line] O(n) O(n) Java 4
N/A Partition Array.java Medium [Array, Quick Sort, Sort, Two Pointers] Java 5
N/A Wiggle Sort.java Medium [Array, Sort] Java 6
N/A The Smallest Difference.java Medium [Array, Sort, Two Pointers] Java 7
259 259. 3Sum Smaller.java Medium [Array, Sort, Two Pointers] Java 8
15 15. 3Sum.java Medium [Array, Sort, Two Pointers] O(n^2) Java 9
1033 1033. Moving Stones Until Consecutive.java Easy [Basic Implementation, Sort] O(1), only 3 elements O(1) Java 10
349 349. Intersection of Two Arrays.java Easy [Binary Search, Hash Table, Sort, Two Pointers] O(m + n) O(m + n) Java 11
350 350. Intersection of Two Arrays II.java Easy [Binary Search, Hash Table, Sort, Two Pointers] (n) (n) Java 12
1048 1048. Longest String Chain.java Medium [Bucket Sort, DP, Hash Table, Sort] O(n) O(n) Java 13
1057 1057. Campus Bikes.java Medium [Bucket Sort, Greedy, PriorityQueue, Sort] O(mn) O(mn) Java 14
274 274.H-Index.java Medium [Bucket Sort, Hash Table, Sort] O(n) O(n) Java 15
973 973. K Closest Points to Origin.java Medium [Divide and Conquer, Heap, Sort] O(klogk) O(k) Java 16
N/A Sort List.java Medium [Divide and Conquer, Linked List, Merge Sort, Sort] Java 17
767 767. Reorganize String.java Medium [Greedy, Hash Table, Heap, Sort, String] O(m), m = # of unique letters O(nLogm), n = length Java 18
1094 1094. Car Pooling.java Medium [Greedy, Heap, PriorityQueue, Sort] O(n) O(1) only use bucket size 1000 Java 19
253 253. Meeting Rooms II.java Medium [Greedy, Heap, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 20
242 242. Valid Anagram.java Easy [Hash Table, Sort] O(n) O(1), unique chars Java 21
N/A Insertion Sort List.java Medium [Linked List, Sort] Java 22
[tool] [tool]. MergeSort.java Medium [Lint, Merge Sort, Sort] O(mlogn) O(n) Java 23
N/A Sort Colors II.java Medium [Partition, Quick Sort, Sort, Two Pointers] Java 24
N/A Sort Letters by Case.java Medium [Partition, Sort, String, Two Pointers] Java 25
N/A Subarray Sum Closest.java Medium [PreSum, PriorityQueue, Sort, Subarray] O(nlogn) O(n) Java 26
252 252. Meeting Rooms.java Easy [PriorityQueue, Sort, Sweep Line] O(nlogn) O(1) Java 27
855 855. Exam Room.java Medium [PriorityQueue, Sort, TreeMap, TreeSet] O(logn) O(n) Java 28
N/A QuickSort.java Medium [Quick Sort, Sort] Java 29
N/A Largest Number.java Medium [Sort] Java 30

Lint (27)

Leetcode# Problem Level Tags Time Space Language Sequence
[lint] [lint]. 2 Sum II.java Medium [Array, Binary Search, Lint, Two Pointers] Java 0
[lint] [lint]. Anagrams.java Medium [Array, Hash Table, Lint] O(n) O(n) Java 1
[lint] [lint]. Subarray Sum.java Easy [Array, Hash Table, Lint, PreSum, Subarray] O(n) O(n) Java 2
[lint] [lint]. Product of Array Exclude Itself.java Medium [Array, Lint] Java 3
[lint] [lint]. Recover Rotated Sorted Array.java Easy [Array, Lint] Java 4
N/A [tool] Quick Select - Median.java Easy [Array, Lint, Quick Select, Quick Sort, Two Pointers] O(n) O(logN) Java 5
[lint] [lint]. Unique Characters.java Easy [Array, Lint, String] Java 6
[lint] [lint]. 3 Sum Closest.java Medium [Array, Lint, Two Pointers] Java 7
[tool] [tool]. Topological Sorting.java Medium [BFS, DFS, Lint, Topological Sort] O(V + E) O(V + E) Java 8
N/A Interval Minimum Number.java Medium [Binary Search, Divide and Conquer, Lint, Segment Tree] Java 9
N/A Count of Smaller Number.java Medium [Binary Search, Lint, Segment Tree] Java 10
N/A Interval Sum.java Medium [Binary Search, Lint, Segment Tree] Java 11
N/A Interval Sum II.java Hard [Binary Search, Lint, Segment Tree] Java 12
N/A Segment Tree Modify.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 13
N/A Segment Tree Query II.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 14
[lint] [lint]. Segment Tree Query.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 15
[lint] [lint]. Segment Tree Build II.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 16
[lint] [lint]. Segment Tree Build.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 17
[tool] [tool]. Hash Function.java Easy [Hash Table, Lint] O(1) get O(n) store map Java 18
[lint] [lint]. Longest Words.java Easy [Hash Table, Lint, String] Java 19
[lint] [lint]. Lowest Common Ancestor II.java Easy [Hash Table, Lint, Tree] Java 20
[lint] [lint]. HashHeap.java Hard [HashHeap, Heap, Lint] Java 21
[lint] [lint]. Heapify.java Medium [HashHeap, Heap, Lint, MinHeap] Java 22
[lint] [lint]. Nth to Last Node in List.java Easy [Linked List, Lint] Java 23
[tool] [tool]. MergeSort.java Medium [Lint, Merge Sort, Sort] O(mlogn) O(n) Java 24
[lint] [lint]. Compare Strings.java Easy [Lint, String] Java 25
[tool] [tool]. UnionFind.java Medium [Lint, Union Find] O(n), with Path Compression O(mN), with Union by Rank O(logN) O(n) Java 26

Design (27)

Leetcode# Problem Level Tags Time Space Language Sequence
380 380. Insert Delete GetRandom O(1).java Medium [Array, Design, Hash Table] O(1) avg O(n) Java 0
244 244. Shortest Word Distance II.java Medium [Array, Design, Hash Table, Two Pointers] O(n) to build map, O(a + b) to query O(n) Java 1
245 245. Shortest Word Distance III.java Medium [Array, Design, Hash Table, Two Pointers] O(n) O(1) Java 2
297 297. Serialize and Deserialize Binary Tree.java Hard [BFS, DFS, Deque, Design, Divide and Conquer, Tree] O(n) O(n) Java 3
173 173. Binary Search Tree Iterator.java Medium [BST, Design, Stack, Tree] O(1) average O(h) Java 4
211 211. Add and Search Word - Data structure design.java Medium [Backtracking, Design, Trie] O(n) to search and to add word < O(mn), depends on the input. m = # of words Java 5
N/A Flatten 2D Vector.java Medium [Design] Java 6
N/A Peeking Iterator.java Medium [Design] Java 7
N/A Singleton.java Easy [Design] Java 8
432 432. All One Data Structure.java Hard [Design, Doubly Linked List] O(1) O(n) Java 9
146 146. LRU Cache.java Medium [Design, Doubly Linked List, Hash Table, Linked List] O(1) O(1) Java 10
716 716. Max Stack.java Medium [Design, Doubly Linked List, Stack, TreeMap] avg O(1), [O(logN) peekMax(), TreeMap]; [O(n) popMax(), TwoStack] O(n) Java 11
N/A Perfect Rectangle.java Hard [Design, Geometry, Hash Table] Java 12
N/A ColorGrid.java Medium [Design, Hash Table] Java 13
N/A LFU Cache.java Hard [Design, Hash Table] Java 14
N/A Unique Word Abbreviation.java Medium [Design, Hash Table] Java 15
359 359. Logger Rate Limiter.java Easy [Design, Hash Table] O(1) O(n) Java 16
170 170. Two Sum III - Data structure design.java Easy [Design, Hash Table, Memoization] O(n) O(n) Java 17
N/A Design Search Autocomplete System.java Hard [Design, Hash Table, MinHeap, PriorityQueue, Trie] input: O(x), where x = possible words, constructor: O(mn) m = max length, n = # of words O(n^2), n = # of possible words, n = # of trie levels; mainlay saving the Map<S, freq> Java 18
295 295. Find Median from Data Stream.java Hard [Design, Heap, MaxHeap, MinHeap] O(1) get, O(logn) addNum O(n) Java 19
N/A Sliding Window Median.java Hard [Design, Heap, MaxHeap, MinHeap, Sliding Window] Java 20
341 341. Flatten Nested List Iterator.java Medium [Design, NestedInteger, Stack] O(n) O(n) Java 21
346 346. Moving Average from Data Stream.java Easy [Design, Queue, Sliding Window] O(1) for next() O(size) for fixed storage Java 22
N/A Implement Stack using Queues.java Easy [Design, Stack] Java 23
N/A Min Stack.java Easy [Design, Stack] Java 24
N/A Implement Queue using Stacks.java Easy [Design, Stack] Java 25
208 208. Implement Trie (Prefix Tree).java Medium [Design, Trie] Java 26

Greedy (24)

Leetcode# Problem Level Tags Time Space Language Sequence
277 277. Find the Celebrity.java Medium [Adjacency Matrix, Array, Graph, Greedy, Pruning] O(n) O(1) Java 0
N/A Jump Game II.java Hard [Array, Coordinate DP, DP, Greedy] O(n) O(1) Java 1
55 55. Jump Game.java Medium [Array, DP, Greedy] O(n) O(1) Java 2
N/A Maximum Subarray II.java Medium [Array, DP, Greedy, PreSum, Sequence DP, Subarray] Java 3
N/A Best Time to Buy and Sell Stock with Transaction Fee.java Medium [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(n), O(1) rolling array Java 4
122 122. Best Time to Buy and Sell Stock II.java Easy [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(1) greedy, O(n) dp Java 5
N/A Minimum Subarray.java Easy [Array, DP, Greedy, Sequence DP, Subarray] O(m) O(1) Java 6
621 621. Task Scheduler.java Medium [Array, Enumeration, Greedy, PriorityQueue, Queue] O(n) O(1) Java 7
1007 1007. Minimum Domino Rotations For Equal Row.java Medium [Array, Greedy] O(n) O(1) Java 8
605 605. Can Place Flowers.java Easy [Array, Greedy] O(n) O(1) Java 9
1053 1053. Previous Permutation With One Swap.java Medium [Array, Greedy, Permutation] O(n) O(1) Java 10
N/A Wildcard Matching.java Hard [Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String] Java 11
1057 1057. Campus Bikes.java Medium [Bucket Sort, Greedy, PriorityQueue, Sort] O(mn) O(mn) Java 12
N/A Cracking the Safe.java Hard [DFS, Greedy, Math] Java 13
N/A Coins in a Line.java Medium [DP, Game Theory, Greedy] Java 14
N/A Majority Number II.java Medium [Enumeration, Greedy] Java 15
N/A Queue Reconstruction by Height.java Medium [Greedy] Java 16
134 134. Gas Station.java Medium [Greedy] O(n) O(1) Java 17
N/A Rearrange String k Distance Apart.java Hard [Greedy, Hash Table, Heap] Java 18
767 767. Reorganize String.java Medium [Greedy, Hash Table, Heap, Sort, String] O(m), m = # of unique letters O(nLogm), n = length Java 19
N/A Remove Duplicate Letters.java Hard [Greedy, Hash Table, Stack] Java 20
1094 1094. Car Pooling.java Medium [Greedy, Heap, PriorityQueue, Sort] O(n) O(1) only use bucket size 1000 Java 21
253 253. Meeting Rooms II.java Medium [Greedy, Heap, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 22
402 402. Remove K Digits.java Medium [Greedy, Monotonous Stack, Stack] O(n) O(n) Java 23

BST (23)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Max Sum of Rectangle No Larger Than K.java Hard [Array, BST, Binary Search, DP, Queue, TreeSet] Java 0
N/A K Empty Slots.java Hard [Array, BST, TreeSet] Java 1
N/A Minimum Absolute Difference in BST.java Easy [BST] Java 2
N/A Remove Node in Binary Search Tree.java Hard [BST] Java 3
N/A Insert Node in a Binary Search Tree .java Easy [BST] Java 4
N/A Zigzag Iterator.java Medium [BST] Java 5
N/A Contains Duplicate III.java Medium [BST] Java 6
315 315. Count of Smaller Numbers After Self.java Hard [BST, Binary Indexed Tree, Binary Search, Divide and Conquer, Segment Tree] O(nlogn) O(n) Java 7
493 493. Reverse Pairs.java Medium [BST, Binary Indexed Tree, Divide and Conquer, Merge Sort, Segment Tree] Java 8
270 270. Closest Binary Search Tree Value.java Easy [BST, Binary Search, Tree] O(logn) O(1) Java 9
N/A Search Range in Binary Search Tree .java Medium [BST, Binary Tree] Java 10
N/A Convert Sorted List to Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Linked List] Java 11
426 426. Convert Binary Search Tree to Sorted Doubly Linked List.java Medium [BST, DFS, Divide and Conquer, Linked List, Tree] O(n) O(1) Java 12
98 98. Validate Binary Search Tree.java Medium [BST, DFS, Divide and Conquer, Tree] O(n) O(logn) Java 13
N/A Kth Smallest Element in a BST.java Medium [BST, DFS, Stack, Tree] Java 14
N/A Recover Binary Search Tree.java Hard [BST, DFS, Tree] Java 15
235 235. Lowest Common Ancestor of a Binary Search Tree.java Easy [BST, DFS, Tree] O(logn) O(logn) Java 16
N/A Unique Binary Search Tree II.java Medium [BST, DP, Divide and Conquer, Tree] Java 17
N/A Unique Binary Search Tree.java Medium [BST, DP, Tree] Java 18
173 173. Binary Search Tree Iterator.java Medium [BST, Design, Stack, Tree] O(1) average O(h) Java 19
938 938. Range Sum of BST.java Easy [BST, Recursion, Tree] Java 20
N/A Inorder Successor in BST.java Medium [BST, Tree] Java 21
N/A Trim a Binary Search Tree.java Easy [BST, Tree] Java 22

PriorityQueue (23)

Leetcode# Problem Level Tags Time Space Language Sequence
621 621. Task Scheduler.java Medium [Array, Enumeration, Greedy, PriorityQueue, Queue] O(n) O(1) Java 0
N/A Number of Airplane in the sky.java Medium [Array, Interval, PriorityQueue, Sort, Sweep Line] Java 1
414 414. Third Maximum Number.java Easy [Array, PriorityQueue] Java 2
56 56. Merge Intervals.java Medium [Array, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 3
57 57. Insert Interval.java Hard [Array, PriorityQueue, Sort, Sweep Line] O(n) O(n) Java 4
N/A The Maze II.java Medium [BFS, DFS, PriorityQueue] Java 5
N/A The Maze III.java Hard [BFS, DFS, PriorityQueue] Java 6
N/A Trapping Rain Water II.java Hard [BFS, Heap, MinHeap, PriorityQueue] Java 7
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 8
1057 1057. Campus Bikes.java Medium [Bucket Sort, Greedy, PriorityQueue, Sort] O(mn) O(mn) Java 9
N/A Ugly Number II.java Medium [DP, Enumeration, Heap, Math, PriorityQueue] O(n) O(n) Java 10
N/A Design Search Autocomplete System.java Hard [Design, Hash Table, MinHeap, PriorityQueue, Trie] input: O(x), where x = possible words, constructor: O(mn) m = max length, n = # of words O(n^2), n = # of possible words, n = # of trie levels; mainlay saving the Map<S, freq> Java 11
23 23. Merge k Sorted Lists.java Medium [Divide and Conquer, Heap, Linked List, Merge Sort, PriorityQueue] O(nlogk) O(logk) Java 12
215 215. Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Select, Quick Sort] O(nlogk) O(k) Java 13
N/A Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Sort] Java 14
1094 1094. Car Pooling.java Medium [Greedy, Heap, PriorityQueue, Sort] O(n) O(1) only use bucket size 1000 Java 15
253 253. Meeting Rooms II.java Medium [Greedy, Heap, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 16
347 347. Top K Frequent Elements.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue] O(n) O(n) Java 17
692 692. Top K Frequent Words.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie] O(n) O(n) Java 18
[lint] [lint]. Merge k Sorted Arrays.java Medium [Heap, MinHeap, PriorityQueue] O(nlogk) O(k) Java 19
N/A Subarray Sum Closest.java Medium [PreSum, PriorityQueue, Sort, Subarray] O(nlogn) O(n) Java 20
252 252. Meeting Rooms.java Easy [PriorityQueue, Sort, Sweep Line] O(nlogn) O(1) Java 21
855 855. Exam Room.java Medium [PriorityQueue, Sort, TreeMap, TreeSet] O(logn) O(n) Java 22

Heap (22)

Leetcode# Problem Level Tags Time Space Language Sequence
743 743. Network Delay Time.java Medium [BFS, DFS, Graph, Heap, PQ] O(nlogn) O(n) Java 0
N/A Trapping Rain Water II.java Hard [BFS, Heap, MinHeap, PriorityQueue] Java 1
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 2
N/A Kth Smallest Element in a Sorted Matrix.java Medium [Binary Search, Heap] O(n + klogn) O(n) Java 3
N/A Ugly Number II.java Medium [DP, Enumeration, Heap, Math, PriorityQueue] O(n) O(n) Java 4
239 239. Sliding Window Maximum.java Hard [Deque, Heap, Sliding Window] O(n) O(n) Java 5
295 295. Find Median from Data Stream.java Hard [Design, Heap, MaxHeap, MinHeap] O(1) get, O(logn) addNum O(n) Java 6
N/A Sliding Window Median.java Hard [Design, Heap, MaxHeap, MinHeap, Sliding Window] Java 7
23 23. Merge k Sorted Lists.java Medium [Divide and Conquer, Heap, Linked List, Merge Sort, PriorityQueue] O(nlogk) O(logk) Java 8
215 215. Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Select, Quick Sort] O(nlogk) O(k) Java 9
N/A Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Sort] Java 10
973 973. K Closest Points to Origin.java Medium [Divide and Conquer, Heap, Sort] O(klogk) O(k) Java 11
N/A Rearrange String k Distance Apart.java Hard [Greedy, Hash Table, Heap] Java 12
767 767. Reorganize String.java Medium [Greedy, Hash Table, Heap, Sort, String] O(m), m = # of unique letters O(nLogm), n = length Java 13
1094 1094. Car Pooling.java Medium [Greedy, Heap, PriorityQueue, Sort] O(n) O(1) only use bucket size 1000 Java 14
253 253. Meeting Rooms II.java Medium [Greedy, Heap, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 15
347 347. Top K Frequent Elements.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue] O(n) O(n) Java 16
692 692. Top K Frequent Words.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie] O(n) O(n) Java 17
[lint] [lint]. HashHeap.java Hard [HashHeap, Heap, Lint] Java 18
[lint] [lint]. Heapify.java Medium [HashHeap, Heap, Lint, MinHeap] Java 19
373 373. Find K Pairs with Smallest Sums.java Medium [Heap, MaxHeap, MinHeap] O(klogk) O(k) Java 20
[lint] [lint]. Merge k Sorted Arrays.java Medium [Heap, MinHeap, PriorityQueue] O(nlogk) O(k) Java 21

Sequence DP (21)

Leetcode# Problem Level Tags Time Space Language Sequence
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 0
N/A Maximum Subarray II.java Medium [Array, DP, Greedy, PreSum, Sequence DP, Subarray] Java 1
N/A Best Time to Buy and Sell Stock with Transaction Fee.java Medium [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(n), O(1) rolling array Java 2
122 122. Best Time to Buy and Sell Stock II.java Easy [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(1) greedy, O(n) dp Java 3
N/A Minimum Subarray.java Easy [Array, DP, Greedy, Sequence DP, Subarray] O(m) O(1) Java 4
N/A Best Time to Buy and Sell Stock III.java Hard [Array, DP, Sequence DP] Java 5
121 121. Best Time to Buy and Sell Stock.java Easy [Array, DP, Sequence DP] Java 6
N/A Wildcard Matching.java Hard [Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String] Java 7
10 10. Regular Expression Matching.java Hard [Backtracking, DP, Double Sequence DP, Sequence DP, String] Java 8
N/A Longest Common Subsequence.java Medium [DP, Double Sequence DP, Sequence DP] Java 9
N/A Longest Common Substring.java Medium [DP, Double Sequence DP, Sequence DP, String] Java 10
72 72. Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, String] O(MN) Java 11
N/A K Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, Trie] Java 12
139 139. Word Break.java Medium [DP, Hash Table, Sequence DP] O(n^2) O(n) Java 13
70 70. Climbing Stairs.java Easy [DP, Memoization, Sequence DP] Java 14
N/A Paint Fence.java Easy [DP, Sequence DP] O(n) O(n) Java 15
N/A Best Time to Buy and Sell Stock IV.java Hard [DP, Sequence DP] Java 16
N/A House Robber II.java Medium [DP, Sequence DP, Status DP] Java 17
198 198. House Robber.java Easy [DP, Sequence DP, Status DP] O(n) O(n) or rolling array O(1) Java 18
256 256. Paint House.java Easy [DP, Sequence DP, Status DP] O(nm), m = # of colors O(nm), or O(1) with rolling array Java 19
265 265. Paint House II.java Hard [DP, Sequence DP, Status DP] O(NK^2): O(K) with rolling array Java 20

Graph (20)

Leetcode# Problem Level Tags Time Space Language Sequence
277 277. Find the Celebrity.java Medium [Adjacency Matrix, Array, Graph, Greedy, Pruning] O(n) O(1) Java 0
1267 1267. Count Servers that Communicate.java Medium [Array, Graph] O(mn) O(m + n) Java 1
269 269. Alien Dictionary.java Hard [BFS, Backtracking, DFS, Graph, Topological Sort] O(n), n = # of graph edges O(n) Java 2
207 207. Course Schedule.java Medium [BFS, Backtracking, DFS, Graph, Topological Sort] O(n) O(n) Java 3
1161 1161. Maximum Level Sum of a Binary Tree.java Medium [BFS, DFS, Graph] O(n) visit all nodes O(n) Java 4
133 133. Clone Graph.java Medium [BFS, DFS, Graph] O(n) O(n) Java 5
743 743. Network Delay Time.java Medium [BFS, DFS, Graph, Heap, PQ] O(nlogn) O(n) Java 6
1203 1203. Sort Items by Groups Respecting Dependencies.java Hard [BFS, DFS, Graph, Topological Sort] O(V + E) to traverse the graph, #nodes + #edges O(V + E) Java 7
210 210. Course Schedule II.java Medium [BFS, DFS, Graph, Topological Sort] O(n) O(n) Java 8
N/A Redundant Connection.java Medium [BFS, DFS, Graph, Tree, Union Find] Java 9
N/A Number of Connected Components in an Undirected Graph.java Medium [BFS, DFS, Graph, Union Find] Java 10
261 261. Graph Valid Tree.java Medium [BFS, DFS, Graph, Union Find] Java 11
399 399. Evaluate Division.java Medium [BFS, DFS, Graph, Union Find] Java 12
N/A Minimum Height Trees.java Medium [BFS, Graph] Java 13
N/A Sliding Puzzle.java Hard [BFS, Graph] Java 14
1306 1306. Jump Game III.java Medium [BFS, Graph] O(n) O(n) Java 15
332 332. Reconstruct Itinerary.java Medium [Backtracking, DFS, Graph] O(n^n) O(�m) Java 16
1043 1043. Partition Array for Maximum Sum.java Medium [DFS, DP, Graph, Memoization] O(n), calc memo[n] O(n) Java 17
N/A Redundant Connection II.java Hard [DFS, Graph, Tree, Union Find] Java 18
1153 1153. String Transforms Into Another String.java Hard [Graph] O(n) O(n) Java 19

Bit Manipulation (19)

Leetcode# Problem Level Tags Time Space Language Sequence
78 78. Subsets.java Medium [Array, BFS, Backtracking, Bit Manipulation, DFS] O(2^n) O(2^n) Java 0
169 169. Majority Element.java Easy [Array, Bit Manipulation, Divide and Conquer, Moore Voting, Sort] O(n) O(1) Java 1
N/A Missing Number.java Easy [Array, Bit Manipulation, Math] Java 2
N/A Convert Integer A to Integer B.java Easy [Bit Manipulation] Java 3
N/A Single Number III.java Medium [Bit Manipulation] Java 4
N/A Total Hamming Distance.java Medium [Bit Manipulation] O(n) O(1), 32-bit array Java 5
N/A Count 1 in Binary.java Easy [Bit Manipulation] Java 6
N/A Binary Gap.java Easy [Bit Manipulation] O(n), n = # of bits O(1) Java 7
N/A Update Bits.java Medium [Bit Manipulation] Java 8
N/A O(1) Check Power of 2.java Easy [Bit Manipulation] Java 9
N/A Swap Bits.java Easy [Bit Manipulation] Java 10
N/A Single Number II.java Medium [Bit Manipulation] Java 11
N/A Sum of Two Integers.java Easy [Bit Manipulation] Java 12
405 405. Convert a Number to Hexadecimal.java Easy [Bit Manipulation] Java 13
N/A Counting Bits.java Medium [Bit Manipulation, Bitwise DP, DP] Java 14
136 136. Single Number.java Easy [Bit Manipulation, Hash Table] Java 15
N/A Power of Two.java Easy [Bit Manipulation, Math] Java 16
N/A Binary Representation.java Hard [Bit Manipulation, String] Java 17
N/A Maximum XOR of Two Numbers in an Array.java Medium [Bit Manipulation, Trie] Java 18

Basic Implementation (18)

Leetcode# Problem Level Tags Time Space Language Sequence
485 485. Max Consecutive Ones.java Easy [Array, Basic Implementation] O(n) O(1) Java 0
119 119. Pascal's Triangle II.java Easy [Array, Basic Implementation] O(k^2), pascal triangle size O(k^2) Java 1
118 118. Pascal's Triangle.java Easy [Array, Basic Implementation, List] O(n^2) based on pascal triangle size O(n^2) Java 2
849 849. Maximize Distance to Closest Person.java Easy [Array, Basic Implementation, Two Pointers] O(n) O(1) Java 3
N/A Cosine Similarity.java Easy [Basic Implementation] Java 4
686 686. Repeated String Match.java Easy [Basic Implementation, Edge Case, String] Java 5
N/A Next Closest Time.java Medium [Basic Implementation, Enumeration, String] Java 6
415 415. Add Strings.java Easy [Basic Implementation, Math, String] O(n) O(n) Java 7
12 12. Integer to Roman.java Medium [Basic Implementation, Math, String] O(n) O(n) Java 8
1033 1033. Moving Stones Until Consecutive.java Easy [Basic Implementation, Sort] O(1), only 3 elements O(1) Java 9
N/A Count and Say.java Easy [Basic Implementation, String] Java 10
788 788. Rotated Digits.java Easy [Basic Implementation, String] O(n) O(n) Java 11
408 408. Valid Word Abbreviation.java Easy [Basic Implementation, String] Java 12
1108 1108. Defanging an IP Address.java Easy [Basic Implementation, String] Java 13
383 383. Ransom Note.java Easy [Basic Implementation, String] Java 14
824 824. Goat Latin.java Easy [Basic Implementation, String] O(n) O(1) Java 15
443 443. String Compression.java Easy [Basic Implementation, String] Java 16
893 893. Groups of Special-Equivalent Strings.java Easy [Basic Implementation, String] Java 17

Segment Tree (17)

Leetcode# Problem Level Tags Time Space Language Sequence
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 0
327 327. Count of Range Sum.java Hard [BIT, Divide and Conquer, Merge Sort, PreSum, Segment Tree] O(nlogn) O(n) Java 1
315 315. Count of Smaller Numbers After Self.java Hard [BST, Binary Indexed Tree, Binary Search, Divide and Conquer, Segment Tree] O(nlogn) O(n) Java 2
493 493. Reverse Pairs.java Medium [BST, Binary Indexed Tree, Divide and Conquer, Merge Sort, Segment Tree] Java 3
308 308. Range Sum Query 2D - Mutable.java Hard [Binary Indexed Tree, Segment Tree] build(n), update(logn), rangeRuery(logn + k) O(n) Java 4
307 307. Range Sum Query - Mutable.java Medium [Binary Indexed Tree, Segment Tree] build O(n), query (logn +k), update O(logn) O(n) Java 5
N/A Interval Minimum Number.java Medium [Binary Search, Divide and Conquer, Lint, Segment Tree] Java 6
N/A Count of Smaller Number.java Medium [Binary Search, Lint, Segment Tree] Java 7
N/A Interval Sum.java Medium [Binary Search, Lint, Segment Tree] Java 8
N/A Interval Sum II.java Hard [Binary Search, Lint, Segment Tree] Java 9
N/A Segment Tree Modify.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 10
N/A Segment Tree Query II.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 11
[lint] [lint]. Segment Tree Query.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 12
[lint] [lint]. Segment Tree Build II.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 13
[lint] [lint]. Segment Tree Build.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 14
850 850. Rectangle Area II.java Hard [Segment Tree, Sweep Line] O(n^2) O(n) Java 15
715 715. Range Module.java Hard [Segment Tree, TreeSet] query O(logn), update O(n) O(n) Java 16

Coordinate DP (17)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Triangles.java Medium [Array, Coordinate DP, DFS, DP, Memoization] Java 0
N/A Longest Increasing Continuous subsequence.java Easy [Array, Coordinate DP, DP] Java 1
62 62. Unique Path.java Medium [Array, Coordinate DP, DP] O(mn) O(mn), rolling array O(n) Java 2
64 64. Minimum Path Sum.java Medium [Array, Coordinate DP, DP] O(mn) O(n) rolling array Java 3
63 63. Unique Paths II.java Medium [Array, Coordinate DP, DP] O(mn) O(mn) Java 4
N/A Jump Game II.java Hard [Array, Coordinate DP, DP, Greedy] O(n) O(1) Java 5
N/A Longest Increasing Continuous subsequence II.java Medium [Array, Coordinate DP, DP, Memoization] Java 6
674 674. Longest Continuous Increasing Subsequence.java Easy [Array, Coordinate DP, DP, Sliding Window] O(n) O(1) Java 7
N/A Russian Doll Envelopes.java Hard [Binary Search, Coordinate DP, DP] Java 8
N/A Longest Increasing Subsequence.java Medium [Binary Search, Coordinate DP, DP, Memoization] O(n^2) dp, O(nLogN) binary search O(n) Java 9
N/A Longest Increasing Path in a Matrix.java Hard [Coordinate DP, DFS, DP, Memoization, Topological Sort] Java 10
N/A Number of Longest Increasing Subsequence.java Medium [Coordinate DP, DP] O(n^2) Java 11
221 221. Maximal Square.java Medium [Coordinate DP, DP] O(mn) O(mn) Java 12
361 361. Bomb Enemy.java Medium [Coordinate DP, DP] O(mn) O(n) by calculating column sum Java 13
523 523. Continuous Subarray Sum.java Medium [Coordinate DP, DP, Math, PreSum, Subarray] O(n) O(k) Java 14
N/A Minimum Swaps To Make Sequences Increasing.java Medium [Coordinate DP, DP, Status DP] Java 15
N/A Longest Valid Parentheses.java Hard [Coordinate DP, Stack, String] Java 16

Union Find (16)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Longest Consecutive Sequence.java Hard [Array, Hash Table, Union Find] Java 0
N/A Redundant Connection.java Medium [BFS, DFS, Graph, Tree, Union Find] Java 1
N/A Number of Connected Components in an Undirected Graph.java Medium [BFS, DFS, Graph, Union Find] Java 2
261 261. Graph Valid Tree.java Medium [BFS, DFS, Graph, Union Find] Java 3
399 399. Evaluate Division.java Medium [BFS, DFS, Graph, Union Find] Java 4
N/A Surrounded Regions.java Medium [BFS, DFS, Matrix DFS, Union Find] Java 5
200 200. Number of Islands.java Medium [BFS, DFS, Matrix DFS, Union Find] O(n) O(n) Java 6
N/A Redundant Connection II.java Hard [DFS, Graph, Tree, Union Find] Java 7
721 721. Accounts Merge.java Medium [DFS, Hash Table, Union Find] Java 8
[tool] [tool]. UnionFind.java Medium [Lint, Union Find] O(n), with Path Compression O(mN), with Union by Rank O(logN) O(n) Java 9
N/A Find the Weak Connected Component in the Directed Graph.java Medium [Union Find] Java 10
N/A Connecting Graph.java Medium [Union Find] Java 11
N/A Connecting Graph III.java Medium [Union Find] Java 12
N/A Bricks Falling When Hit.java Hard [Union Find] Java 13
N/A Connecting Graph II.java Medium [Union Find] Java 14
305 305. Number of Islands II.java Hard [Union Find] O(k * log(mn)) O(mn) Java 15

Enumeration (15)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Rotate Image.java Medium [Array, Enumeration] Java 0
N/A Spiral Matrix.java Medium [Array, Enumeration] Java 1
621 621. Task Scheduler.java Medium [Array, Enumeration, Greedy, PriorityQueue, Queue] O(n) O(1) Java 2
N/A Next Closest Time.java Medium [Basic Implementation, Enumeration, String] Java 3
N/A Strobogrammatic Number II.java Medium [DFS, Enumeration, Math, Sequence DFS] Java 4
N/A Ugly Number II.java Medium [DP, Enumeration, Heap, Math, PriorityQueue] O(n) O(n) Java 5
639 639. Decode Ways II.java Hard [DP, Enumeration, Partition DP] O(n) O(n) Java 6
N/A Majority Number II.java Medium [Enumeration, Greedy] Java 7
36 36. Valid Sudoku.java Easy [Enumeration, Hash Table] (mn) (mn) Java 8
246 246. Strobogrammatic Number.java Easy [Enumeration, Hash Table, Math, Two Pointers] O(n) O(1) Java 9
273 273. Integer to English Words.java Hard [Enumeration, Math, String] O(n) O(1) Java 10
65 65. Valid Number.java Hard [Enumeration, Math, String] O(n) O(1) Java 11
158 158. Read N Characters Given Read4 II - Call multiple times.java Hard [Enumeration, String] O(n) O(n) Java 12
68 68. Text Justification.java Hard [Enumeration, String] O(n) go over words O(maxLength) buffer list Java 13
157 157. Read N Characters Given Read4.java Easy [Enumeration, String] Java 14

Memoization (15)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Triangles.java Medium [Array, Coordinate DP, DFS, DP, Memoization] Java 0
N/A Longest Increasing Continuous subsequence II.java Medium [Array, Coordinate DP, DP, Memoization] Java 1
N/A Coins in a Line III.java Hard [Array, DP, Game Theory, Interval DP, Memoization] Java 2
N/A Coins in a Line II.java Medium [Array, DP, Game Theory, Memoization, MiniMax] Java 3
322 322. Coin Change.java Medium [Backpack DP, DFS, DP, Memoization] O(n * S) O(S) Java 4
140 140. Word Break II.java Hard [Backtracking, DFS, DP, Hash Table, Memoization] O(n!) O(n!) Java 5
N/A Longest Increasing Subsequence.java Medium [Binary Search, Coordinate DP, DP, Memoization] O(n^2) dp, O(nLogN) binary search O(n) Java 6
N/A Longest Increasing Path in a Matrix.java Hard [Coordinate DP, DFS, DP, Memoization, Topological Sort] Java 7
1043 1043. Partition Array for Maximum Sum.java Medium [DFS, DP, Graph, Memoization] O(n), calc memo[n] O(n) Java 8
516 516. Longest Palindromic Subsequence.java Medium [DFS, DP, Interval DP, Memoization] O(n^2) O(n^2) Java 9
1216 1216. Valid Palindrome III.java Hard [DFS, DP, Memoization, String] O(n^2) O(n^2) Java 10
N/A Burst Balloons.java Hard [DP, Divide and Conquer, Interval DP, Memoization] Java 11
509 509. Fibonacci Number.java Easy [DP, Math, Memoization] Java 12
70 70. Climbing Stairs.java Easy [DP, Memoization, Sequence DP] Java 13
170 170. Two Sum III - Data structure design.java Easy [Design, Hash Table, Memoization] O(n) O(n) Java 14

Binary Tree (14)

Leetcode# Problem Level Tags Time Space Language Sequence
987 987. Vertical Order Traversal of a Binary Tree.java Medium [BFS, Binary Tree, DFS, Hash Table, Tree] Java 0
N/A Search Range in Binary Search Tree .java Medium [BST, Binary Tree] Java 1
257 257. Binary Tree Paths.java Easy [Backtracking, Binary Tree, DFS] O(n) O(nlogn) Java 2
114 114. Flatten Binary Tree to Linked List.java Medium [Binary Tree, DFS] O(n) O(n), stacks Java 3
N/A Segment Tree Modify.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 4
N/A Segment Tree Query II.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 5
[lint] [lint]. Segment Tree Query.java Medium [Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree] Java 6
N/A Expression Evaluation.java Hard [Binary Tree, DFS, Expression Tree, Minimum Binary Tree, Stack] Java 7
N/A Convert Expression to Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 8
N/A Convert Expression to Reverse Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 9
[lint] [lint]. Segment Tree Build II.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 10
[lint] [lint]. Segment Tree Build.java Medium [Binary Tree, Divide and Conquer, Lint, Segment Tree] Java 11
N/A Basic Calculator.java Hard [Binary Tree, Expression Tree, Math, Minimum Binary Tree, Stack] Java 12
N/A Expression Tree Build.java Hard [Binary Tree, Expression Tree, Minimum Binary Tree, Stack] Java 13

PreSum (13)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Maximum Average Subarray II.java Review [Array, Binary Search, PreSum] Java 0
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 1
N/A Maximum Subarray II.java Medium [Array, DP, Greedy, PreSum, Sequence DP, Subarray] Java 2
[lint] [lint]. Subarray Sum.java Easy [Array, Hash Table, Lint, PreSum, Subarray] O(n) O(n) Java 3
N/A Submatrix Sum.java Medium [Array, Hash Table, PreSum] Java 4
560 560. Subarray Sum Equals K.java Medium [Array, Hash Table, PreSum, Subarray] O(n) O(n) Java 5
724 724. Find Pivot Index.java Easy [Array, PreSum] O(n) O(1) Java 6
327 327. Count of Range Sum.java Hard [BIT, Divide and Conquer, Merge Sort, PreSum, Segment Tree] O(nlogn) O(n) Java 7
523 523. Continuous Subarray Sum.java Medium [Coordinate DP, DP, Math, PreSum, Subarray] O(n) O(k) Java 8
303 303. Range Sum Query - Immutable.java Easy [DP, PreSum] O(1) query, O(n) setup O(n) Java 9
304 304. Range Sum Query 2D - Immutable.java Medium [DP, PreSum] O(mn) build, O(1) query O(mn) Java 10
N/A Maximum Size Subarray Sum Equals k.java Medium [Hash Table, PreSum, Subarray] O(n) O(n) Java 11
N/A Subarray Sum Closest.java Medium [PreSum, PriorityQueue, Sort, Subarray] O(nlogn) O(n) Java 12

Sliding Window (13)

Leetcode# Problem Level Tags Time Space Language Sequence
674 674. Longest Continuous Increasing Subsequence.java Easy [Array, Coordinate DP, DP, Sliding Window] O(n) O(1) Java 0
1040 1040. Moving Stones Until Consecutive II.java Medium [Array, Sliding Window] O(nlogn) O(n) Java 1
727 727. Minimum Window Subsequence.java Hard [DP, Hash Table, Sliding Window, String, Two Pointers] O(n^2) O(1) Java 2
239 239. Sliding Window Maximum.java Hard [Deque, Heap, Sliding Window] O(n) O(n) Java 3
N/A Sliding Window Median.java Hard [Design, Heap, MaxHeap, MinHeap, Sliding Window] Java 4
346 346. Moving Average from Data Stream.java Easy [Design, Queue, Sliding Window] O(1) for next() O(size) for fixed storage Java 5
340 340. Longest Substring with At Most K Distinct Characters.java Hard [Hash Table, LinkedHashMap, Sliding Window, String, Two Pointers] O(n) O(k) Java 6
76 76. Minimum Window Substring.java Hard [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 7
159 159. Longest Substring with At Most Two Distinct Characters.java Medium [Hash Table, Sliding Window, String, Two Pointers] O(n) O(1) Java 8
438 438. Find All Anagrams in a String.java Medium [Hash Table, Sliding Window, Two Pointers] O(n) O(1) Java 9
632 632. Smallest Range Covering Elements from K Lists.java Hard [Hash Table, Sliding Window, Two Pointers] O(nlogn), n = total elements O(n) to store sorted list Java 10
567 567. Permutation in String.java Medium [Sliding Window, Two Pointers] O(m + n) O(1) Java 11
1004 1004. Max Consecutive Ones III.java Medium [Sliding Window, Two Pointers] O(n) O(1) Java 12

Trie (11)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Word Search II.java Hard [Backtracking, DFS, Trie] Java 0
211 211. Add and Search Word - Data structure design.java Medium [Backtracking, Design, Trie] O(n) to search and to add word < O(mn), depends on the input. m = # of words Java 1
N/A Word Squares.java Hard [Backtracking, Trie] Java 2
N/A Maximum XOR of Two Numbers in an Array.java Medium [Bit Manipulation, Trie] Java 3
N/A K Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, Trie] Java 4
N/A Design Search Autocomplete System.java Hard [Design, Hash Table, MinHeap, PriorityQueue, Trie] input: O(x), where x = possible words, constructor: O(mn) m = max length, n = # of words O(n^2), n = # of possible words, n = # of trie levels; mainlay saving the Map<S, freq> Java 5
208 208. Implement Trie (Prefix Tree).java Medium [Design, Trie] Java 6
692 692. Top K Frequent Words.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie] O(n) O(n) Java 7
N/A Palindrome Pairs.java Hard [Hash Table, String, Trie] Java 8
720 720. Longest Word in Dictionary.java Easy [Hash Table, Trie] O(nlogn) O(n) Java 9
745 745. Prefix and Suffix Search.java Hard [Trie] O(N + Q) O(N) Java 10

MinHeap (11)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Trapping Rain Water II.java Hard [BFS, Heap, MinHeap, PriorityQueue] Java 0
N/A Design Search Autocomplete System.java Hard [Design, Hash Table, MinHeap, PriorityQueue, Trie] input: O(x), where x = possible words, constructor: O(mn) m = max length, n = # of words O(n^2), n = # of possible words, n = # of trie levels; mainlay saving the Map<S, freq> Java 1
295 295. Find Median from Data Stream.java Hard [Design, Heap, MaxHeap, MinHeap] O(1) get, O(logn) addNum O(n) Java 2
N/A Sliding Window Median.java Hard [Design, Heap, MaxHeap, MinHeap, Sliding Window] Java 3
215 215. Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Select, Quick Sort] O(nlogk) O(k) Java 4
N/A Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Sort] Java 5
347 347. Top K Frequent Elements.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue] O(n) O(n) Java 6
692 692. Top K Frequent Words.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie] O(n) O(n) Java 7
[lint] [lint]. Heapify.java Medium [HashHeap, Heap, Lint, MinHeap] Java 8
373 373. Find K Pairs with Smallest Sums.java Medium [Heap, MaxHeap, MinHeap] O(klogk) O(k) Java 9
[lint] [lint]. Merge k Sorted Arrays.java Medium [Heap, MinHeap, PriorityQueue] O(nlogk) O(k) Java 10

Subarray (11)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Minimum Size Subarray Sum.java Medium [Array, Binary Search, Subarray, Two Pointers] O(n) O(1) Java 0
53 53. Maximum Subarray.java Easy [Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray] O(n) O(n), O(1) rolling array Java 1
N/A Maximum Subarray II.java Medium [Array, DP, Greedy, PreSum, Sequence DP, Subarray] Java 2
N/A Minimum Subarray.java Easy [Array, DP, Greedy, Sequence DP, Subarray] O(m) O(1) Java 3
152 152. Maximum Product Subarray.java Medium [Array, DP, PreProduct, Subarray] O(n) O(1) Java 4
[lint] [lint]. Subarray Sum.java Easy [Array, Hash Table, Lint, PreSum, Subarray] O(n) O(n) Java 5
560 560. Subarray Sum Equals K.java Medium [Array, Hash Table, PreSum, Subarray] O(n) O(n) Java 6
N/A Maximum Average Subarray I.java Easy [Array, Subarray] O(n) O(1) Java 7
523 523. Continuous Subarray Sum.java Medium [Coordinate DP, DP, Math, PreSum, Subarray] O(n) O(k) Java 8
N/A Maximum Size Subarray Sum Equals k.java Medium [Hash Table, PreSum, Subarray] O(n) O(n) Java 9
N/A Subarray Sum Closest.java Medium [PreSum, PriorityQueue, Sort, Subarray] O(nlogn) O(n) Java 10

Backpack DP (8)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Combination Sum IV.java Medium [Array, Backpack DP, DP] Java 0
322 322. Coin Change.java Medium [Backpack DP, DFS, DP, Memoization] O(n * S) O(S) Java 1
N/A Backpack VI.java Medium [Backpack DP, DP] Java 2
N/A Backpack V.java Medium [Backpack DP, DP] Java 3
N/A Backpack II.java Medium [Backpack DP, DP] Java 4
N/A Backpack.java Medium [Backpack DP, DP] Java 5
N/A Backpack III.java Hard [Backpack DP, DP] Java 6
518 518. Coin Change 2.java Medium [Backpack DP, DP] O(n) O(n) Java 7

Status DP (8)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Best Time to Buy and Sell Stock with Transaction Fee.java Medium [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(n), O(1) rolling array Java 0
122 122. Best Time to Buy and Sell Stock II.java Easy [Array, DP, Greedy, Sequence DP, Status DP] O(n) O(1) greedy, O(n) dp Java 1
N/A Minimum Swaps To Make Sequences Increasing.java Medium [Coordinate DP, DP, Status DP] Java 2
N/A House Robber III.java Medium [DFS, DP, Status DP, Tree] Java 3
N/A House Robber II.java Medium [DP, Sequence DP, Status DP] Java 4
198 198. House Robber.java Easy [DP, Sequence DP, Status DP] O(n) O(n) or rolling array O(1) Java 5
256 256. Paint House.java Easy [DP, Sequence DP, Status DP] O(nm), m = # of colors O(nm), or O(1) with rolling array Java 6
265 265. Paint House II.java Hard [DP, Sequence DP, Status DP] O(NK^2): O(K) with rolling array Java 7

Sweep Line (7)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Number of Airplane in the sky.java Medium [Array, Interval, PriorityQueue, Sort, Sweep Line] Java 0
56 56. Merge Intervals.java Medium [Array, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 1
57 57. Insert Interval.java Hard [Array, PriorityQueue, Sort, Sweep Line] O(n) O(n) Java 2
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 3
253 253. Meeting Rooms II.java Medium [Greedy, Heap, PriorityQueue, Sort, Sweep Line] O(nlogn) O(n) Java 4
252 252. Meeting Rooms.java Easy [PriorityQueue, Sort, Sweep Line] O(nlogn) O(1) Java 5
850 850. Rectangle Area II.java Hard [Segment Tree, Sweep Line] O(n^2) O(n) Java 6

Quick Sort (7)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A [tool] Quick Select - Median.java Easy [Array, Lint, Quick Select, Quick Sort, Two Pointers] O(n) O(logN) Java 0
N/A Sort Colors.java Medium [Array, Partition, Quick Sort, Sort, Two Pointers] Java 1
N/A Partition Array.java Medium [Array, Quick Sort, Sort, Two Pointers] Java 2
215 215. Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Select, Quick Sort] O(nlogk) O(k) Java 3
N/A Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Sort] Java 4
N/A Sort Colors II.java Medium [Partition, Quick Sort, Sort, Two Pointers] Java 5
N/A QuickSort.java Medium [Quick Sort, Sort] Java 6

Double Sequence DP (6)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Wildcard Matching.java Hard [Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String] Java 0
10 10. Regular Expression Matching.java Hard [Backtracking, DP, Double Sequence DP, Sequence DP, String] Java 1
N/A Longest Common Subsequence.java Medium [DP, Double Sequence DP, Sequence DP] Java 2
N/A Longest Common Substring.java Medium [DP, Double Sequence DP, Sequence DP, String] Java 3
72 72. Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, String] O(MN) Java 4
N/A K Edit Distance.java Hard [DP, Double Sequence DP, Sequence DP, Trie] Java 5

Topological Sort (6)

Leetcode# Problem Level Tags Time Space Language Sequence
269 269. Alien Dictionary.java Hard [BFS, Backtracking, DFS, Graph, Topological Sort] O(n), n = # of graph edges O(n) Java 0
207 207. Course Schedule.java Medium [BFS, Backtracking, DFS, Graph, Topological Sort] O(n) O(n) Java 1
1203 1203. Sort Items by Groups Respecting Dependencies.java Hard [BFS, DFS, Graph, Topological Sort] O(V + E) to traverse the graph, #nodes + #edges O(V + E) Java 2
210 210. Course Schedule II.java Medium [BFS, DFS, Graph, Topological Sort] O(n) O(n) Java 3
[tool] [tool]. Topological Sorting.java Medium [BFS, DFS, Lint, Topological Sort] O(V + E) O(V + E) Java 4
N/A Longest Increasing Path in a Matrix.java Hard [Coordinate DP, DFS, DP, Memoization, Topological Sort] Java 5

Merge Sort (5)

Leetcode# Problem Level Tags Time Space Language Sequence
327 327. Count of Range Sum.java Hard [BIT, Divide and Conquer, Merge Sort, PreSum, Segment Tree] O(nlogn) O(n) Java 0
493 493. Reverse Pairs.java Medium [BST, Binary Indexed Tree, Divide and Conquer, Merge Sort, Segment Tree] Java 1
23 23. Merge k Sorted Lists.java Medium [Divide and Conquer, Heap, Linked List, Merge Sort, PriorityQueue] O(nlogk) O(logk) Java 2
N/A Sort List.java Medium [Divide and Conquer, Linked List, Merge Sort, Sort] Java 3
[tool] [tool]. MergeSort.java Medium [Lint, Merge Sort, Sort] O(mlogn) O(n) Java 4

Permutation (5)

Leetcode# Problem Level Tags Time Space Language Sequence
1053 1053. Previous Permutation With One Swap.java Medium [Array, Greedy, Permutation] O(n) O(1) Java 0
31 31. Next Permutation.java Medium [Array, Permutation] O(n) O(1) Java 1
46 46. Permutations.java Medium [BFS, Backtracking, DFS, Permutation] O(n!) O(n!) Java 2
N/A Palindrome Permutation II.java Medium [Backtracking, Permutation] Java 3
N/A Shuffle an Array.java Medium [Permutation] Java 4

Partition DP (5)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Perfect Squares.java Medium [BFS, DP, Math, Partition DP] Java 0
N/A Copy Books.java Hard [Binary Search, DP, Partition DP] Java 1
639 639. Decode Ways II.java Hard [DP, Enumeration, Partition DP] O(n) O(n) Java 2
N/A Palindrome Partitioning II.java Hard [DP, Partition DP] Java 3
91 91. Decode Ways.java Medium [DP, Partition DP, String] O(n) O(n) Java 4

MaxHeap (5)

Leetcode# Problem Level Tags Time Space Language Sequence
295 295. Find Median from Data Stream.java Hard [Design, Heap, MaxHeap, MinHeap] O(1) get, O(logn) addNum O(n) Java 0
N/A Sliding Window Median.java Hard [Design, Heap, MaxHeap, MinHeap, Sliding Window] Java 1
347 347. Top K Frequent Elements.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue] O(n) O(n) Java 2
692 692. Top K Frequent Words.java Medium [Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie] O(n) O(n) Java 3
373 373. Find K Pairs with Smallest Sums.java Medium [Heap, MaxHeap, MinHeap] O(klogk) O(k) Java 4

Expression Tree (5)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Expression Evaluation.java Hard [Binary Tree, DFS, Expression Tree, Minimum Binary Tree, Stack] Java 0
N/A Convert Expression to Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 1
N/A Convert Expression to Reverse Polish Notation.java Hard [Binary Tree, DFS, Expression Tree, Stack] Java 2
N/A Basic Calculator.java Hard [Binary Tree, Expression Tree, Math, Minimum Binary Tree, Stack] Java 3
N/A Expression Tree Build.java Hard [Binary Tree, Expression Tree, Minimum Binary Tree, Stack] Java 4

TreeMap (5)

Leetcode# Problem Level Tags Time Space Language Sequence
1146 1146. Snapshot Array.java Medium [Array, Hash Table, TreeMap] O(1) set, O(logn) get, O(x) snap, x = # of changes O(n * m), n = array size, m = # of snaps Java 0
N/A My Calendar I.java Medium [Array, TreeMap] Java 1
981 981. Time Based Key-Value Store.java Medium [Binary Search, Hash Table, TreeMap] set O(1), get(logn) O(n) Java 2
716 716. Max Stack.java Medium [Design, Doubly Linked List, Stack, TreeMap] avg O(1), [O(logN) peekMax(), TreeMap]; [O(n) popMax(), TwoStack] O(n) Java 3
855 855. Exam Room.java Medium [PriorityQueue, Sort, TreeMap, TreeSet] O(logn) O(n) Java 4

Game Theory (4)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Coins in a Line III.java Hard [Array, DP, Game Theory, Interval DP, Memoization] Java 0
N/A Coins in a Line II.java Medium [Array, DP, Game Theory, Memoization, MiniMax] Java 1
N/A Nim Game.java Easy [Brainteaser, DP, Game Theory] Java 2
N/A Coins in a Line.java Medium [DP, Game Theory, Greedy] Java 3

Combination (4)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Combination Sum III.java Medium [Array, Backtracking, Combination, DFS] Java 0
39 39. Combination Sum.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(k) stack depth, if not counting result size Java 1
40 40. Combination Sum II.java Medium [Array, Backtracking, Combination, DFS] O(k * 2^n), k = avg rst length O(n) stack depth, if not counting result size Java 2
N/A Combinations.java Medium [Backtracking, Combination, DFS] Java 3

TreeSet (4)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Max Sum of Rectangle No Larger Than K.java Hard [Array, BST, Binary Search, DP, Queue, TreeSet] Java 0
N/A K Empty Slots.java Hard [Array, BST, TreeSet] Java 1
855 855. Exam Room.java Medium [PriorityQueue, Sort, TreeMap, TreeSet] O(logn) O(n) Java 2
715 715. Range Module.java Hard [Segment Tree, TreeSet] query O(logn), update O(n) O(n) Java 3

Interval DP (4)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Coins in a Line III.java Hard [Array, DP, Game Theory, Interval DP, Memoization] Java 0
516 516. Longest Palindromic Subsequence.java Medium [DFS, DP, Interval DP, Memoization] O(n^2) O(n^2) Java 1
N/A Burst Balloons.java Hard [DP, Divide and Conquer, Interval DP, Memoization] Java 2
N/A Scramble String.java Hard [DP, Interval DP, String] Java 3

Binary Indexed Tree (4)

Leetcode# Problem Level Tags Time Space Language Sequence
315 315. Count of Smaller Numbers After Self.java Hard [BST, Binary Indexed Tree, Binary Search, Divide and Conquer, Segment Tree] O(nlogn) O(n) Java 0
493 493. Reverse Pairs.java Medium [BST, Binary Indexed Tree, Divide and Conquer, Merge Sort, Segment Tree] Java 1
308 308. Range Sum Query 2D - Mutable.java Hard [Binary Indexed Tree, Segment Tree] build(n), update(logn), rangeRuery(logn + k) O(n) Java 2
307 307. Range Sum Query - Mutable.java Medium [Binary Indexed Tree, Segment Tree] build O(n), query (logn +k), update O(logn) O(n) Java 3

Bucket Sort (4)

Leetcode# Problem Level Tags Time Space Language Sequence
448 448. Find All Numbers Disappeared in an Array.java Easy [Array, Bucket Sort] O(n) O(1) Java 0
1048 1048. Longest String Chain.java Medium [Bucket Sort, DP, Hash Table, Sort] O(n) O(n) Java 1
1057 1057. Campus Bikes.java Medium [Bucket Sort, Greedy, PriorityQueue, Sort] O(mn) O(mn) Java 2
274 274.H-Index.java Medium [Bucket Sort, Hash Table, Sort] O(n) O(n) Java 3

Doubly Linked List (3)

Leetcode# Problem Level Tags Time Space Language Sequence
432 432. All One Data Structure.java Hard [Design, Doubly Linked List] O(1) O(n) Java 0
146 146. LRU Cache.java Medium [Design, Doubly Linked List, Hash Table, Linked List] O(1) O(1) Java 1
716 716. Max Stack.java Medium [Design, Doubly Linked List, Stack, TreeMap] avg O(1), [O(logN) peekMax(), TreeMap]; [O(n) popMax(), TwoStack] O(n) Java 2

HashHeap (3)

Leetcode# Problem Level Tags Time Space Language Sequence
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 0
[lint] [lint]. HashHeap.java Hard [HashHeap, Heap, Lint] Java 1
[lint] [lint]. Heapify.java Medium [HashHeap, Heap, Lint, MinHeap] Java 2

Cycle Detection (3)

Leetcode# Problem Level Tags Time Space Language Sequence
287 287. Find the Duplicate Number.java Medium [Array, Binary Search, Binary Search on Value, Cycle Detection, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 0
142 142. Linked List Cycle II.java Medium [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 1
141 141. Linked List Cycle.java Easy [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 2

Minimum Binary Tree (3)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Expression Evaluation.java Hard [Binary Tree, DFS, Expression Tree, Minimum Binary Tree, Stack] Java 0
N/A Basic Calculator.java Hard [Binary Tree, Expression Tree, Math, Minimum Binary Tree, Stack] Java 1
N/A Expression Tree Build.java Hard [Binary Tree, Expression Tree, Minimum Binary Tree, Stack] Java 2

MiniMax (3)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Coins in a Line II.java Medium [Array, DP, Game Theory, Memoization, MiniMax] Java 0
N/A Predict the Winner.java Medium [DP, MiniMax] Java 1
843 843. Guess the Word.java Hard [MiniMax] TODO TODO Java 2

NestedInteger (3)

Leetcode# Problem Level Tags Time Space Language Sequence
339 339. Nested List Weight Sum.java Easy [BFS, DFS, NestedInteger] O(n) O(h), h = levels Java 0
364 364. Nested List Weight Sum II.java Medium [DFS, NestedInteger] O(n), visit all nodes O(h), depth Java 1
341 341. Flatten Nested List Iterator.java Medium [Design, NestedInteger, Stack] O(n) O(n) Java 2

Queue (3)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Max Sum of Rectangle No Larger Than K.java Hard [Array, BST, Binary Search, DP, Queue, TreeSet] Java 0
621 621. Task Scheduler.java Medium [Array, Enumeration, Greedy, PriorityQueue, Queue] O(n) O(1) Java 1
346 346. Moving Average from Data Stream.java Easy [Design, Queue, Sliding Window] O(1) for next() O(size) for fixed storage Java 2

Monotonous Stack (3)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Largest Rectangle in Histogram.java Hard [Array, Monotonous Stack, Stack] Java 0
402 402. Remove K Digits.java Medium [Greedy, Monotonous Stack, Stack] O(n) O(n) Java 1
739 739. Daily Temperatures.java Medium [Hash Table, Monotonous Stack, Stack] O(n) O(n) Java 2

Partition (3)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Sort Colors.java Medium [Array, Partition, Quick Sort, Sort, Two Pointers] Java 0
N/A Sort Colors II.java Medium [Partition, Quick Sort, Sort, Two Pointers] Java 1
N/A Sort Letters by Case.java Medium [Partition, Sort, String, Two Pointers] Java 2

Slow Fast Pointer (3)

Leetcode# Problem Level Tags Time Space Language Sequence
287 287. Find the Duplicate Number.java Medium [Array, Binary Search, Binary Search on Value, Cycle Detection, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 0
142 142. Linked List Cycle II.java Medium [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 1
141 141. Linked List Cycle.java Easy [Cycle Detection, Linked List, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 2

Sequence DFS (2)

Leetcode# Problem Level Tags Time Space Language Sequence
22 22. Generate Parentheses.java Medium [Backtracking, DFS, Sequence DFS, String] O(2^n) O(2^n) Java 0
N/A Strobogrammatic Number II.java Medium [DFS, Enumeration, Math, Sequence DFS] Java 1

Double Recursive (2)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Binary Tree Longest Consecutive Sequence II.java Medium [DFS, Divide and Conquer, Double Recursive, Tree] Java 0
N/A Path Sum III.java Easy [DFS, Double Recursive, Tree] Java 1

Moore Voting (2)

Leetcode# Problem Level Tags Time Space Language Sequence
169 169. Majority Element.java Easy [Array, Bit Manipulation, Divide and Conquer, Moore Voting, Sort] O(n) O(1) Java 0
229 229. Majority Element II.java Medium [Array, Moore Voting] O(n) (1) Java 1

Recursion (2)

Leetcode# Problem Level Tags Time Space Language Sequence
938 938. Range Sum of BST.java Easy [BST, Recursion, Tree] Java 0
698 698. Partition to K Equal Sum Subsets.java Medium [DFS, DP, Recursion] O(k^(n-k) * k!) O(n) Java 1

Brainteaser (2)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Nim Game.java Easy [Brainteaser, DP, Game Theory] Java 0
319 319. Bulb Switcher.java Medium [Brainteaser, Math] O(1) O(1) Java 1

Matrix DFS (2)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Surrounded Regions.java Medium [BFS, DFS, Matrix DFS, Union Find] Java 0
200 200. Number of Islands.java Medium [BFS, DFS, Matrix DFS, Union Find] O(n) O(n) Java 1

Quick Select (2)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A [tool] Quick Select - Median.java Easy [Array, Lint, Quick Select, Quick Sort, Two Pointers] O(n) O(logN) Java 0
215 215. Kth Largest Element in an Array.java Medium [Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Select, Quick Sort] O(nlogk) O(k) Java 1

PreProduct (2)

Leetcode# Problem Level Tags Time Space Language Sequence
152 152. Maximum Product Subarray.java Medium [Array, DP, PreProduct, Subarray] O(n) O(1) Java 0
238 238. Product of Array Except Self.java Medium [Array, PreProduct] O(n) O(1) Java 1

BIT (2)

Leetcode# Problem Level Tags Time Space Language Sequence
218 218. The Skyline Problem.java Hard [BIT, Divide and Conquer, HashHeap, Heap, PriorityQueue, Segment Tree, Sweep Line] O(n^2logn) O(n) Java 0
327 327. Count of Range Sum.java Hard [BIT, Divide and Conquer, Merge Sort, PreSum, Segment Tree] O(nlogn) O(n) Java 1

Deque (2)

Leetcode# Problem Level Tags Time Space Language Sequence
297 297. Serialize and Deserialize Binary Tree.java Hard [BFS, DFS, Deque, Design, Divide and Conquer, Tree] O(n) O(n) Java 0
239 239. Sliding Window Maximum.java Hard [Deque, Heap, Sliding Window] O(n) O(n) Java 1

Geometry (2)

Leetcode# Problem Level Tags Time Space Language Sequence
149 149. Max Points on a Line.java Hard [Array, Geometry, Hash Table, Math] O(n^2) O() Java 0
N/A Perfect Rectangle.java Hard [Design, Geometry, Hash Table] Java 1

Edge Case (2)

Leetcode# Problem Level Tags Time Space Language Sequence
41 41. First Missing Positive.java Hard [Analysis, Array, Edge Case] O(n) O(1) Java 0
686 686. Repeated String Match.java Easy [Basic Implementation, Edge Case, String] Java 1

PQ (1)

Leetcode# Problem Level Tags Time Space Language Sequence
743 743. Network Delay Time.java Medium [BFS, DFS, Graph, Heap, PQ] O(nlogn) O(n) Java 0

LinkedHashMap (1)

Leetcode# Problem Level Tags Time Space Language Sequence
340 340. Longest Substring with At Most K Distinct Characters.java Hard [Hash Table, LinkedHashMap, Sliding Window, String, Two Pointers] O(n) O(k) Java 0

List (1)

Leetcode# Problem Level Tags Time Space Language Sequence
118 118. Pascal's Triangle.java Easy [Array, Basic Implementation, List] O(n^2) based on pascal triangle size O(n^2) Java 0

Garph (1)

Leetcode# Problem Level Tags Time Space Language Sequence
785 785. Is Graph Bipartite.java Medium [BFS, DFS, Garph] O(n) O(n) Java 0

KMP (1)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Shortest Palindrome.java Hard [KMP, String] Java 0

Binary Search on Value (1)

Leetcode# Problem Level Tags Time Space Language Sequence
287 287. Find the Duplicate Number.java Medium [Array, Binary Search, Binary Search on Value, Cycle Detection, Slow Fast Pointer, Two Pointers] O(n) O(1) Java 0

Analysis (1)

Leetcode# Problem Level Tags Time Space Language Sequence
41 41. First Missing Positive.java Hard [Analysis, Array, Edge Case] O(n) O(1) Java 0

Interval (1)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Number of Airplane in the sky.java Medium [Array, Interval, PriorityQueue, Sort, Sweep Line] Java 0

Bitwise DP (1)

Leetcode# Problem Level Tags Time Space Language Sequence
N/A Counting Bits.java Medium [Bit Manipulation, Bitwise DP, DP] Java 0

Semaphore (1)

Leetcode# Problem Level Tags Time Space Language Sequence
1117 1117. Building H2O.java Medium [Lock, Semaphore, Thread] Java 0

Pruning (1)

Leetcode# Problem Level Tags Time Space Language Sequence
277 277. Find the Celebrity.java Medium [Adjacency Matrix, Array, Graph, Greedy, Pruning] O(n) O(1) Java 0

Reservior Sampling (1)

Leetcode# Problem Level Tags Time Space Language Sequence
398 398. Random Pick Index.java Medium [Reservior Sampling] O(n) O(n) for input int[], O(1) extra space used Java 0

Rotation (1)

Leetcode# Problem Level Tags Time Space Language Sequence
189 189. Rotate Array.java Easy [Array, Rotation] Java 0

Adjacency Matrix (1)

Leetcode# Problem Level Tags Time Space Language Sequence
277 277. Find the Celebrity.java Medium [Adjacency Matrix, Array, Graph, Greedy, Pruning] O(n) O(1) Java 0

Lock (1)

Leetcode# Problem Level Tags Time Space Language Sequence
1117 1117. Building H2O.java Medium [Lock, Semaphore, Thread] Java 0

Thread (1)

Leetcode# Problem Level Tags Time Space Language Sequence
1117 1117. Building H2O.java Medium [Lock, Semaphore, Thread] Java 0

Backpack (1)

Leetcode# Problem Level Tags Time Space Language Sequence
416 416. Partition Equal Subset Sum.java Medium [Backpack, DP] Java 0

Two Stacks (1)

Leetcode# Problem Level Tags Time Space Language Sequence
145 145. Binary Tree Postorder Traversal.java Medium [Stack, Tree, Two Stacks] O(n) O(n) Java 0

Tree DP (1)

Leetcode# Problem Level Tags Time Space Language Sequence
124 124. Binary Tree Maximum Path Sum.java Hard [DFS, DP, Tree, Tree DP] O(n) O(logn) Java 0