#9 most askedVery commonMedium1D DP
Coin Change
New to 1D DP? Learn it from scratch firstDynamic Programming, Demystified โ
๐ข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.Return the fewest coins needed to make amount, or -1 if it can't be made. You have unlimited coins of each value.
coin_change([1, 2, 5], 11) โ 3 (5 + 5 + 1).
๐งช Practice
Write your solution, then press Run tests. Explain your approach out loud as you go.
def coin_change(coins, amount):
pass
Output appears here. Press Run or Ctrl/โ + Enter.
Try it first. Struggling for a few minutes is how it sticks.