"Dynamic programming has the scariest name in algorithms and one of the simplest ideas: don't solve the same subproblem twice. Richard Bellman literally picked the name to sound impressive to a budget committee. Don't let it intimidate you."
The Name Is a Marketing Trick
'Dynamic programming' sounds like advanced sorcery. It isn't. Bellman, who coined it in the 1950s, later admitted he chose 'dynamic' because it sounded exciting and 'programming' to disguise mathematical research from a cost-cutting boss. The actual idea is humble: solve each subproblem once, store the answer, and reuse it instead of recomputing. You already did this in the recursion track when memoizing Fibonacci collapsed O(2ⁿ) to O(n). That was dynamic programming. You've been doing DP without the scary label.
The Two Conditions
A problem yields to DP when it has both of these:
- Overlapping subproblems: a naive recursion ends up solving the same smaller problems over and over (the repeated subtrees in the Fibonacci recursion tree). This is what makes caching pay off — if every subproblem were unique, there'd be nothing to reuse.
- Optimal substructure: the optimal solution to the whole problem is built from optimal solutions to its subproblems. (The shortest path from A to C through B uses the shortest A-to-B and B-to-C paths.) This is what lets you combine sub-answers into the full answer.
Both present → DP applies. Subproblems don't overlap → it's just divide-and-conquer (nothing to cache). No optimal substructure → you can't safely build the answer from parts, and DP won't work.
DP vs Divide-and-Conquer
The distinction from the last track is precise. Divide-and-conquer (merge sort) splits into subproblems that are independent — the two halves share nothing, so there's nothing to cache. Dynamic programming splits into subproblems that overlap — the same sub-answers are needed in many places, so caching them is the entire win. Same recursive instinct; the difference is whether the subproblems repeat. When they repeat, you stop recomputing and start remembering. That shift from 'recompute' to 'remember' is the whole discipline.