Dynamic programming is both a mathematical optimization method and a computer programming method that breaks down complicated problems to sub-problems. Dynamic programming uses recursion to solve problems which would be solved iteratively in an equivalent tree or network model. The technique was introduced by Richard Bellman (1952), who used it to solve a variety of problems including those in the fields of mathematics, economics, statistics, engineering, accounting, linguistics and other areas of science.
Dynamic programming solves a problem by breaking it down into subproblems and storing their solutions as part of the original problem's solution. The approach works by first solving each subproblem as if it were the only one; that is done by solving only for the first variable in each subproblem. Then, all values from all subproblems are summed up together to get the final solution for the entire original problem. This technique is known as "memoization".
Even if you never encounter them, the concepts learned are useful for solving many other kinds of coding challenges. Let's practice some dynamic programming problems!
How do I use this section?