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
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)
Monotonic StackNext greater/smaller elementO(n)
BacktrackingConstraint satisfactionVaries

Progress Tracker

This section is updated by the LLM as you solve problems

Problems solved: 1 Patterns started: 1 / 17

Top-K Elements — 1 problem solved (LC-347 ✅)

1 item under this folder.