LeetCode
This is my coding interview notebook: pattern reminders at the top, and one markdown page per completed problem underneath. The problem pages live in study/leetcodes/, so new captures from the Tampermonkey script can be added without deciding which topic file owns the question.
Use the pattern sections as a quick diagnosis checklist before solving. LeetCode tags can overlap heavily, so the important split here is the main thinking pattern, not every possible tag.
Pattern Notes
Arrays & Strings
Use this bucket for flat sequence problems where the core work is scanning, comparing, grouping, or maintaining a window.
Patterns to know
- Two pointers: fast/slow, inward/outward, sorted pair search.
- Sliding window for longest, shortest, or counted substring/subarray constraints.
- Prefix sum and difference array for repeated range calculations.
- Sorting plus greedy when order unlocks a simpler local choice.
- Binary search on index or answer space.
How to identify
The input is mainly an array or string, and the question asks for a pair, triplet, range, substring, frequency, or ordered scan.
Dynamic Programming
Use this when the answer can be built from smaller repeated states and a local decision contributes to a global optimum or count.
Patterns to know
- 1D DP for Fibonacci-style transitions, house robber, and simple recurrence states.
- 2D grid DP for unique paths, minimum path sum, and obstacle grids.
- Subsequence DP for LIS, LCS, edit distance, and matching problems.
- Knapsack, interval DP, state machines, bitmask DP, and digit DP for richer state design.
How to identify
Look for maximum/minimum ways, cost, length, repeated subproblems, or a recursive brute force that keeps recomputing the same state.
Trees
Tree problems are usually about choosing the right traversal and deciding what each recursive call should return to its parent.
Patterns to know
- DFS preorder, inorder, and postorder.
- BFS level order with a queue.
- Divide and conquer for height, balance, diameter, path sum, and subtree checks.
- BST-specific inorder ordering and binary-search-like pruning.
- Lowest common ancestor and ancestor/path tracking.
How to identify
The input is `root`, or the problem talks about height, depth, level, ancestor, subtree, balanced, path, or BST order.
Graphs
Graph questions are about relationships: reachability, connectivity, ordering, shortest path, or traversing a grid as implicit nodes.
Patterns to know
- BFS and DFS for traversal, islands, and connected components.
- Union-find for grouping and cycle detection.
- Topological sort for prerequisites and dependency order.
- Dijkstra or Bellman-Ford for weighted shortest paths.
How to identify
The input has nodes and edges, a 2D grid with movement, prerequisites, components, cycles, or a shortest path requirement.
Design Problems
Design problems ask you to maintain state across method calls while meeting operation complexity constraints.
Patterns to know
- Hash map plus linked list for LRU-style ordering.
- Hash map plus array for randomized set operations.
- Queue/deque for recent-event windows, rate limiters, and hit counters.
- Heap or ordered structures when min/max priority matters.
How to identify
The prompt asks you to implement a class with operations such as `push`, `pop`, `get`, `put`, `add`, or `remove`.
Backtracking
Backtracking is controlled brute force: build a candidate, recurse, then undo the choice cleanly.
Patterns to know
- Subsets, combinations, and permutations.
- Board search such as word search, N-Queens, and Sudoku.
- Pruning invalid branches early.
How to identify
The problem asks for all possible solutions, all valid arrangements, or all combinations under constraints.
Heaps & Priority Queues
Use heaps when you repeatedly need the current smallest, largest, or best candidate without fully sorting every time.
Patterns to know
- Kth largest or smallest.
- Top-k frequent elements.
- Merge k sorted streams.
- Scheduling and running median style problems.
How to identify
The problem repeatedly asks for min/max, top-k, or the next best item while data changes.
Linked Lists
Linked list problems are pointer discipline problems. The main risk is losing references or mishandling edge cases.
Patterns to know
- Fast/slow pointers for cycles and middle nodes.
- Dummy nodes for cleaner insert/delete logic.
- Full or partial reversal.
- Merge two lists or k lists.
How to identify
The input involves nodes with `.next`, or the prompt asks to reverse, reorder, merge, detect a cycle, or remove nodes.
Math & Bit Manipulation
This bucket is for problems where the trick is an arithmetic property, representation detail, or binary operation.
Patterns to know
- GCD, LCM, divisibility, modulo, and fast exponentiation.
- XOR identities and bit masks.
- Counting bits, powers of two, and subset representation.
How to identify
Constraints are very large, the prompt mentions modulo/divisibility, or the solution depends on binary representation.
Completed Questions
| ID | Question | Difficulty | Primary Pattern | Tags | Time Taken | Solved |
|---|---|---|---|---|---|---|
| 0001 | Two Sum | Easy | Arrays & Strings | Array, Hash Table | 02:19 | 2026-05-03 |
| 0002 | Add Two Numbers | Medium | Linked Lists | Linked List, Math, Recursion | 06:36 | 2026-05-04 |
| 0003 | Longest Substring Without Repeating Characters | Medium | Arrays & Strings | Hash Table, String, Sliding Window | 17:46 | 2026-05-07 |
| 0005 | Longest Palindromic Substring | Medium | Dynamic Programming | Two Pointers, String, Dynamic Programming | 00:01 | 2026-05-09 |
| 0006 | Zigzag Conversion | Medium | Arrays & Strings | String | 03:39 | 2026-05-12 |
| 0007 | Reverse Integer | Medium | Math & Bit Manipulation | Math | 10:18 | 2026-05-12 |
| 0008 | String to Integer (atoi) | Medium | Arrays & Strings | String | 08:22 | 2026-05-12 |
| 0009 | Palindrome Number | Easy | Math & Bit Manipulation | Math | 08:51 | 2026-05-03 |
| 0011 | Container With Most Water | Medium | Arrays & Strings | Array, Two Pointers, Greedy | 00:01 | 2026-05-12 |
| 0012 | Integer to Roman | Medium | Arrays & Strings | Hash Table, Math, String | 23:09 | 2026-05-15 |
| 0013 | Roman to Integer | Easy | Arrays & Strings | Hash Table, Math, String | 19:51 | 2026-05-03 |
| 0014 | Longest Common Prefix | Easy | Trees | Array, String, Trie | 13:19 | 2026-05-04 |
| 0015 | 3Sum | Medium | Arrays & Strings | Array, Two Pointers, Sorting | 11:37 | 2026-05-15 |
| 0016 | 3Sum Closest | Medium | Arrays & Strings | Array, Two Pointers, Sorting | 22:46 | 2026-05-16 |
| 0017 | Letter Combinations of a Phone Number | Medium | Backtracking | Hash Table, String, Backtracking | 15:49 | 2026-05-21 |
| 0018 | 4Sum | Medium | Arrays & Strings | Array, Two Pointers, Sorting | 10:14 | 2026-05-21 |
| 0019 | Remove Nth Node From End of List | Medium | Linked Lists | Linked List, Two Pointers | 10:07 | 2026-05-21 |
| 0020 | Valid Parentheses | Easy | Design Problems | String, Stack | 00:00 | 2026-05-04 |
| 0021 | Merge Two Sorted Lists | Easy | Linked Lists | Linked List, Recursion | 13:19 | 2026-05-04 |
| 0022 | Generate Parentheses | Medium | Dynamic Programming | String, Dynamic Programming, Backtracking | 14:14 | 2026-05-16 |
| 0026 | Remove Duplicates from Sorted Array | Easy | Arrays & Strings | Array, Two Pointers | 08:52 | 2026-05-04 |
| 0027 | Remove Element | Easy | Arrays & Strings | Array, Two Pointers | 19:03 | 2026-05-04 |
| 0028 | Find the Index of the First Occurrence in a String | Easy | Arrays & Strings | Two Pointers, String, String Matching | 19:03 | 2026-05-04 |
| 0029 | Divide Two Integers | Medium | Math & Bit Manipulation | Math, Bit Manipulation | 08:58 | 2026-05-21 |
| 0045 | Jump Game II | Medium | Dynamic Programming | Array, Dynamic Programming, Greedy | 09:12 | 2026-05-16 |
| 0053 | Maximum Subarray | Medium | Dynamic Programming | Array, Divide and Conquer, Dynamic Programming | 12:20 | 2026-05-16 |
| 0055 | Jump Game | Medium | Dynamic Programming | Array, Dynamic Programming, Greedy | 00:00 | 2026-05-16 |
| 0062 | Unique Paths | Medium | Dynamic Programming | Math, Dynamic Programming, Combinatorics | 02:42 | 2026-05-16 |
| 0063 | Unique Paths II | Medium | Dynamic Programming | Array, Dynamic Programming, Matrix | 00:00 | 2026-05-16 |
| 0064 | Minimum Path Sum | Medium | Dynamic Programming | Array, Dynamic Programming, Matrix | 21:16 | 2026-05-16 |
| 0066 | Plus One | Easy | Arrays & Strings | Array, Math | 11:48 | 2026-05-21 |
| 0067 | Add Binary | Easy | Arrays & Strings | Math, String, Bit Manipulation, Simulation | 05:40 | 2026-05-21 |