Minimum Coin Change

H · hardPracticedp

Given coin denominations and a target amount, find the minimum number of coins needed.

Input
3 11
1 5 6
Output
2
DP: dp[0]=0, dp[i]=min(dp[i-c]+1) for each coin c. Initialize dp with infinity.
5+6=11, using 2 coins
← Merge Two ArraysMove All Zeros to End →
Report an issue with this question