Merge pull request #470 from jackeyjia/patch-4

add js solution for coin-change-2
This commit is contained in:
程序员Carl
2021-07-08 09:54:40 +08:00
committed by GitHub

View File

@ -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];
}
```
-----------------------