Dynamic programming (also known as DP) is a technique for solving a specific class of problems. The given problem can be divided into smaller sub-problems, and these smaller sub-problems are then divided into even smaller ones, and you may notice some over-lapping subproblems during this process. Furthermore, the optimal solutions to the subproblems contribute to the optimal solution of the given problem.

There are two ways

- Memoization: Top-Down
- Tabulation: Bottom-Up

**Memoization:** Solving the given problem by breaking it down and then return the solved answer.