Back to problems Solve on LeetCode → See #198 House Robber →

Coin Change

LeetCode 322 • Medium • Dynamic Programming

Input: coins = [1, 2, 5], amount = 11  →  Output: 3
Min coins to make amount. dp[i] = min(dp[i-c]+1) for c in coins. dp[0]=0.

TimeO(amount × coins)nested loops
SpaceO(amount)dp array
Amount: 0 dp[amt]:
dp[i]
Current coin
Result
dp
Ready
Press Play or Step. We fill each amount with the fewest coins; narration translates the highlighted line into English.