solulubeta
Sign in
Recursion & Memo / DP patterns for coding tests
04.07 · Lesson

Unlimited Supply: Coin Change

When an item can be used again and again, taking it keeps you on the same item. One small change to take-or-skip solves fewest coins and number of ways.

10 min 2 videos Quiz Pro

Change one rule from the last lesson: each item can be used any number of times. Now taking item i keeps you on i, because you may take it again.

TakeSkip
Each item oncef(i + 1, rem − w[i])f(i + 1, rem)
Unlimited supplyf(i, rem − w[i])f(i + 1, rem)

That’s the whole difference. The state and the memo size stay the same.

solulu Pro

Continue this lesson with Pro

Inside: 3 sections · 2 videos · quiz.

  • Try it
  • Fewest coins
  • Number of ways
Lifetime ₹1,999 ₹999 · Launch offer
Mark this as done when you are finished.

Item 33 of 44 · updated 2026-10-13