Pattern library

Learn the pattern, then reuse it.

Each guide connects a recognition signal, a core invariant, a deliberate practice order, and every worked problem in that family.

Algorithm pattern28

Arrays & Hashing

Frequency maps, prefix sums, in-place scans. You need constant-time lookup, frequency counts, deduplication, or information about a prefix.

Study this pattern →
Algorithm pattern15

Two Pointers

Converge from both ends or chase in one pass. A sorted order, opposing ends, or two sequences lets one pointer eliminate choices for the other.

Study this pattern →
Algorithm pattern16

Sliding Window

A moving range that grows and shrinks. The question asks about a contiguous range whose validity changes predictably as either edge moves.

Study this pattern →
Algorithm pattern26

Stack

LIFO bookkeeping for matching and order. The most recent unresolved item must be handled first, or you need the next greater or smaller boundary.

Study this pattern →
Algorithm pattern19

Binary Search

Halve the search space every step. Answers become permanently feasible after a boundary, or the sorted search space can discard half at once.

Study this pattern →
Algorithm pattern24

Linked List

Pointer surgery on chained nodes. The problem is about rearranging, locating, or comparing nodes without random access.

Study this pattern →
Algorithm pattern6

Intervals

Sort, then sweep and merge ranges. Each item occupies a range and the answer depends on overlap, coverage, or scheduling order.

Study this pattern →
Algorithm pattern9

Matrix

2-D traversal and in-place transforms. The input is a grid whose row, column, diagonal, or neighborhood geometry matters.

Study this pattern →
Algorithm pattern48

Dynamic Programming

Carry the best answer so far, build up. Brute force repeats the same state, and the future depends on a compact summary of earlier choices.

Study this pattern →
Algorithm pattern19

Recursion & Backtracking

Explore choices, undo, and try the next. The solution explores a decision tree, decomposes a structure, or must undo a choice before trying another.

Study this pattern →
Algorithm pattern53

Binary Trees

Recursive structure — visit, go left, go right. Each answer can be composed from a node and the answers of its child subtrees.

Study this pattern →
Algorithm pattern18

Strings

Scan, compare, and build character by character. Character order, matching, parsing, or repeated substrings drive the state.

Study this pattern →
Algorithm pattern13

Greedy

Take the locally best choice and never look back. A locally optimal choice can be proven never to reduce the quality of the remaining solution.

Study this pattern →
Algorithm pattern17

Heaps

Priority queues — always grab the smallest or largest fast. You repeatedly need the smallest or largest active candidate while the candidate set changes.

Study this pattern →
Algorithm pattern42

Graphs

BFS, DFS, shortest paths and spanning trees. Entities form arbitrary connections and the task asks about reachability, ordering, shortest paths, or connectivity.

Study this pattern →
Algorithm pattern10

Trie

Prefix trees for words and bits. Many words or bit strings share prefixes and queries repeatedly walk those prefixes.

Study this pattern →
Algorithm pattern14

Bit Manipulation

XOR tricks, masks, and shifting instead of arithmetic. Parity, subsets, powers of two, or pair cancellation can be represented directly by bits.

Study this pattern →
Algorithm pattern17

Maths

Divisors, primes, and number theory for interviews. Number properties, divisibility, digit structure, or bounded arithmetic matter more than a data structure.

Study this pattern →