Sep 25, 2025•1 min read

DP is easy

Yes am not saying that but it is, you just need to get things for the basics

Two methods

  • Recursive Top Down Memoization
  • Iterative Bottom Up Tabulation

Coin Change II https://leetcode.com/problems/coin-change-ii/

  • Paste each line of the problem in the code as comments this will make understanding easier
  • Take a look at the examples input and outputs
  • Write a short summary of the problem
  • Now think of those small independently <img width="1326" height="743" alt="How to make observation" src="https://github.com/user-attachments/assets/df8553cc-f554-4e77-b359-f49cd2569a3b" />
  • Take ith or skip ith ... and so on
  • Now simulate an general example let say ith. <img width="1328" height="742" alt="How to simulate recursion" src="https://github.com/user-attachments/assets/5e7aa784-7a31-4a71-978b-a0748370c752" />
  • Recursion is your friend then <img width="1333" height="751" alt="How to make recursion your friend" src="https://github.com/user-attachments/assets/8d648118-85b5-4c4d-853f-25d97cedd2cc" />

Lets sum up

<img width="1335" height="760" alt="DP is easy" src="https://github.com/user-attachments/assets/9ec330eb-448e-40d6-bd0c-9b0720857ab9" />

DP = Decision parameterization