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

  1. Memoization: Top-Down
  2. Tabulation: Bottom-Up

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

anmol sethi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store