Interactive course by Aditya Verma

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 and a worked solution. Answer the four questions yourself, then compare your reasoning with the breakdown. Most problems also include an animated table.

Medium Problems26

Water OverflowgridcountingFull breakdownLongest Common SubsequencestringoptimizationFull breakdownLongest Increasing SubsequenceoptimizationlinearFull breakdownEdit DistancestringminimizationFull breakdownLargest Divisible SubsetsubsetoptimizationlinearFull breakdownWeighted Job SchedullingoptimizationlinearFull breakdown0-1 Knapsack ProblemknapsackoptimizationFull breakdownPrinting Items in 0/1 KnapsackknapsackreconstructionFull breakdownUnbounded KnapsackknapsackoptimizationFull breakdownWord Break ProblemstringcountinglinearFull breakdownTile Stacking ProblemcountinggridcombinatoricsFull breakdownBox-Stacking ProblemoptimizationlinearFull breakdownPartition ProblemsubsetpartitionFull breakdownLongest Palindromic SubsequencepalindromestringintervalFull breakdownLongest Common Increasing SubsequencestringoptimizationFull breakdownAll distinct subset (or subsequence) sumssubsetcountingFull breakdownCount DerangementscountingcombinatoricslinearFull breakdownMinimum insertions for palindromepalindromestringintervalFull breakdownWildcard Pattern MatchingstringgridFull breakdownRegular Expression MatchingstringgridFull breakdownArrange Balls with adjacent of different typescountingcombinatoricsFull breakdownLongest Subsequence with 1 adjacent differenceoptimizationlinearFull breakdownMaximum size square sub-matrix with all 1sgridoptimizationFull breakdownBellman–Ford AlgorithmgraphminimizationFull breakdownFloyd Warshall AlgorithmgraphminimizationFull breakdownMaximum Tip CalculatoroptimizationgridFull breakdown

Every problem has a worked explanation and code. Use the animated tables where available, then return to the notes for revision.