WorkspaceLearning path
Level 5 · Advanced Problem Solving
BUILD YOUR INTUITION

Dynamic Programming

Define a reusable answer for each state, then compute states from already solved smaller ones.

THE MENTAL MODEL

When should this come to mind?

Define a reusable answer for each state, then compute states from already solved smaller ones.

Overlapping subproblemsOptimal substructureRepeated recursionMin/max number of choices

What makes it work

State meaning and dependency order must be explicit. Unreachable states need a separate representation.

When to choose something else

If a valid greedy choice can be proven and no overlapping states remain, DP may add unnecessary work.

RecursionMemoizationBottom-up DPSpace optimization

First name the repeated state. Cache its answer, order its dependencies, then retain only states still needed. Coin Change demonstrates the bottom-up step.

See the pattern in action

Change the input. Follow the state. Make it yours.