Dynamic programming (DP) solves problems with overlapping subproblems and optimal substructure by computing each subproblem once and reusing the result. The two styles are memoization (top-down) and tabulation (bottom-up).
The idea
Naive recursion recomputes the same subproblems exponentially. DP caches them, collapsing exponential work into polynomial.
