Algorithms & Data Structures
See the pattern before you solve it.
Core interview patterns, each anchored to a mnemonic and a worked TypeScript solution. Study the signal, then recall the shape until naming the pattern is instant.
32 patterns ยท 8 categories
Scanning & Windows
Sweep the array with moving pointers.6 patterns๐ช
Binary Search
The Executioner halves it every time.
โ๏ธ
Two Pointers
Two knights close from both ends.
๐ช
Sliding Window
A glass pane slides across the counter.
๐งพ
Prefix Sum
An accountant's running receipt.
๐
Interval Problems
Overlapping calendars, sorted & stapled.
๐ช
Sorted Matrix Search
The Climber starts at the corner and never backtracks.
Stacks, Queues & Heaps
Order and priority over a stream.5 patternsTrees & Recursion
Branch, recurse, and combine.5 patterns๐ท๏ธ
Tree DFS ยท Preorder
Stamp the node on arrival, then descend.
๐
Tree DFS ยท Inorder
Left wing, sign the door, right wing โ values come out sorted.
๐งฎ
Tree DFS ยท Postorder
Clear both children first, then the parent โ results bubble up.
๐ฟ
Tree BFS
Light every level before the next.
๐
Backtracking
Try a path, then undo every step.
Graphs & Networks
Nodes, edges, and the paths between.7 patterns๐ฏ๏ธ
Graph DFS
Down each tunnel to its dead end.
๐ก
Graph BFS
Signal ripples outward, ring by ring.
๐ชข
Union Find
A merchant ropes islands together.
๐ ๏ธ
Topological Sort
Fit each part before what needs it.
๐งญ
Dijkstra
Always extend the cheapest route first.
๐ง
Grid BFS
Distance spreads across cells.
๐
Minimum Spanning Tree
Connect every island as cheaply as possible.