Algorithms & Data Structures

See the pattern before you solve it.

Core interview patterns, each anchored to a mnemonic and a TypeScript template. Study the signal, then recall the shape until naming the pattern is instant.

29 patterns ยท 8 categories

Scanning & Windows

Sweep the array with moving pointers.5 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.

Stacks, Queues & Heaps

Order and priority over a stream.5 patterns
๐Ÿฝ๏ธ
Stack
A teetering stack of plates.
๐Ÿท
Monotonic Stack
Bottles racked in strict order.
๐ŸŽŸ๏ธ
Queue
A first-come-first-served line.
๐Ÿ•ถ๏ธ
Heap / Priority Queue
A bouncer keeps only the top K.
๐Ÿš‚
Linked List
Coupled carriages, forward only.

Trees & Recursion

Branch, recurse, and combine.3 patterns
๐Ÿ“š
Tree DFS
Down one shelf to the floor, then the next.
๐ŸŒฟ
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.

Dynamic Programming

Remember solved subproblems.3 patterns
๐Ÿ—‚๏ธ
1D Dynamic Programming
Every answer already filed away.
๐Ÿ’ฐ
Knapsack DP
Pack the sack for maximum worth.
๐Ÿงฎ
2D Dynamic Programming
A grid of solved decisions.

Hashing & Sets

Constant-time lookup, counts, and membership.2 patterns
๐Ÿ—ƒ๏ธ
Hash Map Counting
Every key has a labeled drawer.
๐Ÿงฟ
Set Membership
A guard recognizes every forbidden token.

Sorting & Selection

Order first, then exploit the order.2 patterns
๐Ÿงน
Sorting
Sweep chaos into useful order.
๐ŸŽฏ
Quickselect
Partition until the target rank is fixed.

Strings & Tries

Prefixes, characters, and word paths.2 patterns
๐ŸŒฒ
Trie
Each letter opens the next branch.
๐Ÿ”Ž
String Matching
Match characters without re-reading the hallway.