Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e23fc4

Browse files
Merge pull requestyoungyangyang04#472 from jackeyjia/patch-5
add js solution for combinationSum4
2 parentsb648995 +1e34731 commit6e23fc4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎problems/0377.组合总和Ⅳ.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,25 @@ func combinationSum4(nums []int, target int) int {
201201
}
202202
```
203203

204+
Javascript:
205+
```javascript
206+
constcombinationSum4= (nums,target)=> {
207+
208+
let dp=Array(target+1).fill(0);
209+
dp[0]=1;
210+
211+
for(let i=0; i<= target; i++) {
212+
for(let j=0; j<nums.length; j++) {
213+
if (i>= nums[j]) {
214+
dp[i]+= dp[i- nums[j]];
215+
}
216+
}
217+
}
218+
219+
return dp[target];
220+
};
221+
```
222+
204223

205224

206225
-----------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp