Named puzzles and recreational problems, grouped by the technique that solves them. Each linked page has the full treatment; this is the index and the β€œwhat technique does this need” map.

Problems, not algorithms

These are questions whose answers happen to be famous β€” distinct from the named algorithms, which are methods. The full set lives in Classical Problems.

Recreational classics

PuzzleTechnique
Tower of Hanoirecursion; moves; the -th move is disk
Josephus problemrecurrence, or bit rotation for
N-Queensbacktracking with bitmasks
Knight’s tourbacktracking + Warnsdorff’s rule
8- / 15-puzzleA*, bidirectional BFS; a parity invariant decides solvability
Water jugBFS on states; solvable iff target
Wolf, goat and cabbageBFS on a small state space
Bridge and torchgreedy / small DP
Lights Out Gaussian elimination
SudokuDancing Links / exact cover
Magic square, Latin squaredirect construction; see Classic Constructions
Pancake sortinggreedy; flips
Peg solitairean invariant (a colouring argument)
KΓΆnigsberg bridgesEulerian path conditions

Probability puzzles

PuzzleAnswer
Monty Hallswitching wins with probability
Birthday paradox23 people for 50%
Coupon collector
100 prisoners and the boxescycle-following gives
Secretary problemreject the first , then take the best so far
Poisoned winebinary encoding: testers

The 100 prisoners result is the most surprising: a strategy raising the success probability from to , using nothing but the cycle structure of a random permutation.

Number puzzles

PuzzleTechnique
Trailing zeroes of $n!$Legendre:
Derangements
The Catalan familybrackets, triangulations, BSTs β€” all
Chicken McNugget / Frobenius for coprime
Staircase countingFibonacci
Digit sums, repunits, palindromic numbersdigit DP

Trailing zeroes β€” the derivation

, and always has more factors of 2 than of 5, so the count is :

long long trailingZeroes(long long n) {
    long long c = 0;
    for (long long p = 5; p <= n; p *= 5) c += n / p;
    return c;
}

. In base , factor and take .

Array and sequence classics

PuzzleTechnique
Maximum subarrayKadane
Trapping rain watertwo pointers, or monotonic stack
Largest rectangle in a histogrammonotonic stack
Majority elementBoyer-Moore voting
Dutch national flagthree-way partition
Celebrity problem elimination
Gas station / circular tourgreedy with a running deficit
Stock buy and sellgreedy or DP by transaction count
Next greater elementmonotonic stack

Optimisation classics

ProblemStatus
Egg droppingDP; a binomial closed form exists
KnapsackDP; NP-hard
Coin changeDP; greedy fails in general
Rod cuttingunbounded knapsack
AssignmentHungarian,
Stable marriageGale-Shapley,
TSPNP-hard; Held-Karp for
Subset sum / partitionNP-hard; pseudo-polynomial DP

See also: Classical Problems Β· Problem Pattern Recognition Β· Named Algorithms