Skip to content

Commit 97636cc

Browse files
Merge pull request #470 from jackeyjia/patch-4
add js solution for coin-change-2
2 parents 4598c47 + 01ee8a2 commit 97636cc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

problems/0518.零钱兑换II.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ func change(amount int, coins []int) int {
243243
}
244244
```
245245

246+
Javascript:
247+
```javascript
248+
const change = (amount, coins) => {
249+
let dp = Array(amount + 1).fill(0);
250+
dp[0] = 1;
251+
252+
for(let i =0; i < coins.length; i++) {
253+
for(let j = coins[i]; j <= amount; j++) {
254+
dp[j] += dp[j - coins[i]];
255+
}
256+
}
257+
258+
return dp[amount];
259+
}
260+
```
261+
246262

247263

248264
-----------------------

0 commit comments

Comments
 (0)