LeetCode Patterns
Recurring algorithmic patterns for coding interviews, organized by technique. Each pattern page includes a Go template, recognition heuristics, and a curated problem set graded by difficulty.
Core Patterns
| Pattern | Key Signal | Typical Complexity |
|---|---|---|
| Arrays & Hashing | Counting, dedup, group, pair sum | O(n) |
| Sliding Window | Contiguous subarray/substring | O(n) |
| Two Pointers | Sorted array, pair finding | O(n) |
| Fast & Slow Pointers | Cycle detection, middle of list | O(n) |
| Merge Intervals | Overlapping intervals | O(n log n) |
| Cyclic Sort | Numbers in range [0, n] | O(n) |
| In-Place Reversal of Linked List | Reverse without extra space | O(n) |
| Graph BFS | Level-order, shortest path | O(V+E) |
| Graph DFS | Path finding, exhaustive search | O(V+E) |
| Two Heaps | Median finding, scheduling | O(n log n) |
| Permutations | Generate all combinations | O(2^n) |
| Modified Binary Search | Sorted/rotated array | O(log n) |
| Top-K Elements | K largest/smallest/frequent | O(n log k) |
| K-Way Merge | Merge sorted lists | O(n log k) |
| DP Patterns | Overlapping subproblems | Varies |
| Topological Sort | Ordering with dependencies | O(V+E) |
| Stack-Based | Bracket matching, undo, next element | O(n) |
| Monotonic Stack | Next greater/smaller element | O(n) |
| Backtracking | Constraint satisfaction | Varies |
Progress Tracker
This section is updated by the LLM as you solve problems
Problems solved: 3 Patterns started: 4 / 18
Arrays & Hashing — 1 / 10 problems solved (LC-347 ✅) Two Pointers — 1 problem solved (LC-5 ✅) Stack-Based — 1 problem solved (LC-20 ✅) Top-K Elements — 1 problem solved (LC-347 ✅)