DP is recursion with the recomputation removed. The hard part is never the code — it is choosing the state.

The four questions

  1. What is the state? (what do I need to remember)
  2. What is the transition? (how do states combine)
  3. What is the base case?
  4. What is the order? (every state must be ready before it is used)

Foundations

Classic Problems

DP Flavours

Optimizations

See also: Subset DP · DP Cheatsheet

28 items under this folder.