Grokking Dynamic Programming Patterns for Coding Interviews
Vote

0% completed

​

Solution: Minimum Coin Change

.....

.....

.....

Like the course? Get enrolled and start learning!
A

Anonymous

· 5 years ago

class Solution { public int coinChange(int[] coins, int amount) { if(amount == 0) return 0; if(coins.length == 0 && amount > 0) return -1;

int[] dp = new int[amount+1];

Arrays.fill(dp, amount+1); dp[0] = 0;

for(int i=1; i

A

Anonymous

· 5 years ago

Any idea why '+1' is added to count1 i.e. while including the coin at the current index?

Show 4 replies

Reading Progress

0%


Vote for new content