48 worked problems

Dynamic Programming

Carry the best answer so far, build up. Brute force repeats the same state, and the future depends on a compact summary of earlier choices.

Recognition signal

When should you think of Dynamic Programming?

Brute force repeats the same state, and the future depends on a compact summary of earlier choices.

Core invariant

What must stay true?

Each DP state stores the best or total answer for one precisely defined subproblem.

Practice in a deliberate order

What to learn in this cluster

  1. 01One-dimensional recurrence
  2. 02Grid and subsequence DP
  3. 03Interval, stock, and partition DP

All Dynamic Programming problems

48 of 48 walkthroughs
Continue the cluster

Related patterns and study guides