diff --git "a/problems/0518.\351\233\266\351\222\261\345\205\221\346\215\242II.md" "b/problems/0518.\351\233\266\351\222\261\345\205\221\346\215\242II.md" index 08043ea397..3f907da9eb 100644 --- "a/problems/0518.\351\233\266\351\222\261\345\205\221\346\215\242II.md" +++ "b/problems/0518.\351\233\266\351\222\261\345\205\221\346\215\242II.md" @@ -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]; +} +``` + -----------------------