Interactive Course

Dynamic Programming,
Visually.

Stop memorizing patterns. Build the intuition. Every recurrence is animated step-by-step. Watch a DP table fill cell by cell, trace the dependencies, scrub backward to any moment, and rebuild the whole thing with a different input.

What is DP?

Those who cannot remember the past are condemned to repeat it. Dynamic programming is a way to solve a hard problem by breaking it into smaller, overlapping subproblems and solving each of those exactly once, storing the answer in a table so you never recompute it.

The payoff is enormous. A naive recursive Fibonacci makes ~1.5 million calls for n = 30. The DP version does 31 writes. This course shows you that gap, visually, on every lesson.

The Four Questions

Ask these before writing code. They turn DP from a collection of formulas into a repeatable problem-solving process.

1. Define the state

What does one entry mean? Say it in a complete sentence before using symbols. For example: dp[i] is the number of ways to reach stair i.

2. Derive the recurrence

What final decision could produce this state? Turn each possible decision into a smaller subproblem, then combine their answers.

3. Set bases and order

Which smallest states already have known answers? Which dependencies must be solved before each new state can be calculated?

4. Choose the execution

Use memoization to solve needed states top-down, or tabulation to fill them bottom-up. The state, base cases, and recurrence stay the same.

Your checkpoint: explain all four in plain language before you code. If one answer is unclear, the DP design is not finished.

Why this course is different

  • Scrub any direction.

    Step backward through a DP table and every cell, arrow, and code highlight stays consistent. The timeline is reversible by construction, not by special-casing.

  • Change the input, instantly.

    Drag n from 1 to 12 and the trace rebuilds live. See how the table, the dependency graph, and the operation count all scale, not just the final answer.

  • Read the code alongside the table.

    Every animated step highlights the exact line of source it executes. The visualization is the algorithm; there is no hidden logic.

Problem Set

78 problems, grouped by how much they ask of you. Do a lesson first, then come here: each problem gives you the statement, waits while you answer the four questions yourself, and only then shows you the recurrence and fills the table.

Medium Problems26

Water OverflowgridcountingStatement onlyLongest Common SubsequencestringoptimizationStatement onlyLongest Increasing SubsequenceoptimizationlinearFull breakdownEdit DistancestringminimizationStatement onlyLargest Divisible SubsetsubsetoptimizationlinearFull breakdownWeighted Job SchedullingoptimizationlinearFull breakdown0-1 Knapsack ProblemknapsackoptimizationStatement onlyPrinting Items in 0/1 KnapsackknapsackreconstructionStatement onlyUnbounded KnapsackknapsackoptimizationStatement onlyWord Break ProblemstringcountinglinearFull breakdownTile Stacking ProblemcountinggridcombinatoricsStatement onlyBox-Stacking ProblemoptimizationlinearFull breakdownPartition ProblemsubsetpartitionStatement onlyLongest Palindromic SubsequencepalindromestringintervalStatement onlyLongest Common Increasing SubsequencestringoptimizationStatement onlyAll distinct subset (or subsequence) sumssubsetcountingStatement onlyCount DerangementscountingcombinatoricslinearFull breakdownMinimum insertions for palindromepalindromestringintervalStatement onlyWildcard Pattern MatchingstringgridStatement onlyRegular Expression MatchingstringgridStatement onlyArrange Balls with adjacent of different typescountingcombinatoricsStatement onlyLongest Subsequence with 1 adjacent differenceoptimizationlinearFull breakdownMaximum size square sub-matrix with all 1sgridoptimizationStatement onlyBellman–Ford AlgorithmgraphminimizationStatement onlyFloyd Warshall AlgorithmgraphminimizationStatement onlyMaximum Tip CalculatoroptimizationgridStatement only

Breakdowns are being written family by family. Every problem's statement is here now; the animated tables land per batch.