diff --git a/problems/0377.组合总和Ⅳ.md b/problems/0377.组合总和Ⅳ.md index d0394706..2ee009b3 100644 --- a/problems/0377.组合总和Ⅳ.md +++ b/problems/0377.组合总和Ⅳ.md @@ -201,6 +201,25 @@ func combinationSum4(nums []int, target int) int { } ``` +Javascript: +```javascript +const combinationSum4 = (nums, target) => { + + let dp = Array(target + 1).fill(0); + dp[0] = 1; + + for(let i = 0; i <= target; i++) { + for(let j = 0; j < nums.length; j++) { + if (i >= nums[j]) { + dp[i] += dp[i - nums[j]]; + } + } + } + + return dp[target]; +}; +``` + -----------------------