Skip to content

Reading material

Short, focused primers on the patterns behind the problems. Read one, then go solve something that uses it.

Foundations

Arrays & Hashing

Indexing, hash maps, and frequency counting.

12 min
Foundations

Strings

Frequency maps, in-place pointer tricks, efficient building.

12 min
Foundations

Sorting

Comparators, linear-time counting sorts, and Quickselect.

13 min
Foundations

Stacks & Queues

LIFO/FIFO and the monotonic stack pattern.

11 min
Foundations

Linked Lists

Pointer surgery, fast/slow pointers, reversal, dummy heads.

14 min
Foundations

Trees & Traversals

DFS orders, BFS by level, and the BST invariant.

18 min
Foundations

Graphs

Modeling, DFS/BFS, components, and topological sort.

16 min
Foundations

Simulation & Enumeration

Modeling a process directly — cleanly and correctly.

9 min
Patterns

Two Pointers

Converging and chasing pointers that turn O(n^2) into O(n).

9 min
Patterns

Sliding Window

A moving window for subarray/substring questions.

11 min
Patterns

Prefix Sums & Difference Arrays

Cumulative totals for O(1) range queries and subarray counts.

11 min
Patterns

Binary Search

Halve the search space — on arrays and monotonic answers.

12 min
Patterns

Tries (Prefix Trees)

A character-keyed tree for fast prefix and word lookups.

10 min
Patterns

Heaps & Priority Queues

Top-K, merging, and scheduling with always-on min/max access.

13 min
Patterns

Ordered Sets

Keep data sorted as it changes — neighbor and rank queries.

11 min
Patterns

Backtracking

Build candidates incrementally and undo choices.

14 min
Patterns

Union–Find (DSU)

Near-O(1) merging and connectivity — components, cycles.

12 min
Patterns

1-D Dynamic Programming

Overlapping subproblems on a line — memoization & tabulation.

16 min
Patterns

Greedy

Locally optimal choices that give a global optimum.

11 min
Patterns

Intervals

Sort by an endpoint, then sweep — merge, insert, count overlaps.

10 min
Patterns

Math & Geometry

Matrix manipulation, number theory, and arithmetic tricks.

12 min
Patterns

Bit Manipulation

XOR tricks, masks, and counting bits for O(1)-space wins.

10 min
Patterns

String Matching & Hashing

Find patterns fast — KMP and rolling hashes.

13 min
Patterns

Divide & Conquer

Split, solve halves, combine — and reason about cost.

11 min
Patterns

Design (Data Structures)

Compose maps, heaps, and lists to hit required time bounds.

14 min
Patterns

Randomized Algorithms

Uniform sampling, fair shuffles, expected-time selection.

10 min
Patterns

Game Theory

Two-player optimal play — minimax, winning states, Nim.

11 min
Advanced

Advanced Graphs

Weighted shortest paths, MSTs, and Bellman-Ford.

15 min
Advanced

2-D Dynamic Programming

Grids and two-sequence problems needing two dimensions.

17 min
Advanced

Segment & Fenwick Trees

Logarithmic range queries with point/range updates.

16 min