Here is the list of questions I solved along with the language(s) used and relevant topics. Questions and solutions I believe to be important or unique are bolded.
There are detailed explanations in the notes directory. It includes the explanations of my approach in English, Lua-style pseudocode, runtime analysis, and relevant programming language skills that could be used.
I prioritize approaching questions algorithmically. But I also love Python one liners.
- 88. Merge Sorted Array (Easy, Python):
Merge
subroutine fromMergeSort
- 27. Remove Element (Easy, Java): Pointless question
- 26. Remove Duplicates from Sorted Array (Easy, C++): Build-up for the 80.
- 80. Remove Duplicates from Sorted Array II (Medium, C++): Remove dup template
- 169. Majority Element (Easy, C++, Python): Hashmap (C++), Boyer-Moore majority vote algorithm (Python)
- 189. Rotate Array (Medium, C++, Python): Modulus (Python), Array reversal (C++)
- 121. Best Time to Buy and Sell Stock (Easy, Python, C++): Sliding window, Kadane's Algorithm
- 122. Best Time to Buy and Sell Stock II (Medium, Python): Greedy algorithm
- 55. Jump Game (Medium, C++, Python): Two Pointers. Both solutions use the same logic.
- 45. Jump Game II (Medium, C++, Python): Two Pointers, DP
- 274. H-Index (Medium, C++, Python): Array sorting. Both C++ and Python solutions are doing the same thing, but C++ solution is more efficient (same big-O bound) AND more readable
- 380. Insert Delete GetRandom O(1): OOP, random
- 238. Product of Array Except Self (Medium, Python): Prefix sum
- 134. Gas Station (Medium, C++): Greedy algorithm
- [135. Candy](./notes/0135-candy.md: Greedy algorithm
- 125. Valid Palindrome (Easy, C++): Two Pointers
- 392. Is Subsequence (Easy, Python, C++): Two Pointers
- 167. Two Sum II - Input Array Is Sorted (Medium, Python, C++): Two Pointers
- 11. Container With Most Water (Medium, Python): Two Pointers
- 15. 3Sum (Medium, Python): Two pointers, Array sorting, Set
- [209. Minimum Size Subarray Sum](./notes/0209-min-size-subarr-sum.md: Sliding window
- 3. Longest Substring Without Repeating Characters (Medium, C++): Sliding window, Hashmap
- 30. Substring with Concatenation of All Words (Hard, Python): Sliding Window, Hashmap, Substring
- 383. Ransome Note: Hashmap
- 205. Isomorphic Strings (Easy, Python, C++): Hashmap, checking if key exists
- 290. Word Pattern (Easy, C++): Hashmap, checking if key exists
- 242. Valid Anagram (Easy, Python): Python one-liner
- 49. Group Anagrams (Medium, Python): Hashmap, string hashmap
- 1. Two Sum (Easy, C++): Hashmap
- 202. Happy Number (Easy, C++, Python): Hashmap, Floyd's tortoise and hare algorithm
- 219. Contains Duplicate II (Easy, Python): Hashmap
- 228. Summary Ranges (Easy, C++): String appending
- 20. Valid Parentheses (Easy, C++): Stack operations, dictionary
- 71. Simplify Path (Medium, Python): Stack, string split
- 141. Linked List Cycle (Easy, C++, Python): Floyd's tortoise and hare algorithm
- 2. Add Two Numbers (Medium, C++): Dummy node for return list
- 21. Merge Two Sorted Lists (Easy, C++):
Merge
algorithm fromMergeSort
, dummy node for return list - 138. Copy List with Random Pointer (Medium, C++): Hashmap
- 104. Maximum Depth of Binary Tree (Easy, Python, C++): Recursive DFS (Python), iterative BFS using queue (C++)
- 100. Same Tree (Easy, C++, Python): Recursive DFS (C++, Python), (TODO: iterative BFS using queue)
- 226. Invert Binary Tree (Easy, C++): Recursive DFS (C++), (TODO: iterative BFS using queue)
- 101. Symmetric Tree (Easy, Python): Recursive DFS, (TODO: iterative BFS using queue)
- 35. Search Insert Position (Easy, C++): Binary search
- 215. Kth Largest Element in an Array (Medium, C++, Python, Java): Min-heap (C++), QuickSelect (Python), array sorting (Java)
- 67. Add Binary (Easy, C++): Binary addition, casting
- 136. Single Number (Easy, C++): XOR
- 9. Palindrome Number (Easy, Python, C++): Python one-liner
- 70. Climbing Stairs (Easy, C++, Python): Tabulation
- 198. House Robber (Medium, C++): Tabulation
- 139. Word Break (Medium, Python): Tabulation, Substring