Skip to content

Commit

Permalink
add js solution for coin-change-2
Browse files Browse the repository at this point in the history
  • Loading branch information
jackeyjia authored Jul 5, 2021
1 parent 1da6ff7 commit 01ee8a2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions problems/0518.零钱兑换II.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ func change(amount int, coins []int) int {
}
```

Javascript:
```javascript
const change = (amount, coins) => {
let dp = Array(amount + 1).fill(0);
dp[0] = 1;

for(let i =0; i < coins.length; i++) {
for(let j = coins[i]; j <= amount; j++) {
dp[j] += dp[j - coins[i]];
}
}

return dp[amount];
}
```



-----------------------
Expand Down

0 comments on commit 01ee8a2

Please sign in to comment.