Overview
The named algorithms in the earlier sections are instances of a smaller number of recurring
Two Pointers & Sliding Window
Both patterns replace a nested loop with a single pass by maintaining two indices that only ever move
Divide & Conquer
Divide and conquer breaks a problem into independent subproblems of the same kind, solves those
Greedy Algorithms
A greedy algorithm makes the choice that looks best right now and never reconsiders it. When that
Dynamic Programming
Dynamic programming applies when a problem has overlapping subproblems — the same sub-computation
Backtracking
Backtracking searches a space of candidate solutions by building them one choice at a time, and
Prefix Sums & Difference Arrays
Summing a range of an array costs time proportional to the range. Do it once and nobody notices; do it
Monotonic Stack & Queue
"For each element, find the nearest element to the right that is bigger" looks like it needs a nested
Intervals & Sweep Line
A calendar full of meetings, a set of (start, end) ranges to merge, a question like "how many
Fast & Slow Pointers
A singly-linked list, or anything shaped like one — a permutation's i -> p[i] mapping, a
Recursion → Memoization → Tabulation
Dynamic Programming names the idea — overlapping subproblems plus
Top-K & Streaming
"Find the k largest" looks like a sorting problem, and sorting solves it — but sorting also computes
Cheat Sheet
This page is a reference, not a tutorial — see Problem-Solving Patterns Overview for a