Amount:8
412
1x
Dynamic Programming

Coin Change (Min Coins)

Step 1 of 6

Given coin denominations and a target amount, find the minimum number of coins needed. A classic DP problem that shows why greedy fails โ€” and how bottom-up tabulation always finds the optimal answer.

Why Greedy Fails

Greedy always picks the largest coin first. With coins [1, 3, 4] and target 6: greedy picks 4+1+1 = 3 coins. DP finds 3+3 = 2 coins. The optimal substructure of this problem requires DP, not greedy.

Greedy
4
1
1
3 coins โœ•
DP
3
3
2 coins โœ“