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

PatternKey SignalTypical Complexity
Arrays & HashingCounting, dedup, group, pair sumO(n)
Sliding WindowContiguous subarray/substringO(n)
Two PointersSorted array, pair findingO(n)
Fast & Slow PointersCycle detection, middle of listO(n)
Merge IntervalsOverlapping intervalsO(n log n)
Cyclic SortNumbers in range [0, n]O(n)
In-Place Reversal of Linked ListReverse without extra spaceO(n)
Graph BFSLevel-order, shortest pathO(V+E)
Graph DFSPath finding, exhaustive searchO(V+E)
Two HeapsMedian finding, schedulingO(n log n)
PermutationsGenerate all combinationsO(2^n)
Modified Binary SearchSorted/rotated arrayO(log n)
Top-K ElementsK largest/smallest/frequentO(n log k)
K-Way MergeMerge sorted listsO(n log k)
DP PatternsOverlapping subproblemsVaries
Topological SortOrdering with dependenciesO(V+E)
Stack-BasedBracket matching, undo, next elementO(n)
Monotonic StackNext greater/smaller elementO(n)
BacktrackingConstraint satisfactionVaries

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 ✅)