mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
Merge branch 'youngyangyang04:master' into master
This commit is contained in:
@ -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];
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
-----------------------
|
||||
|
Reference in New Issue
Block a user