File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public int combinationSum4 (int [] nums , int target ) {
3
+ Map <Integer , Integer > map = new HashMap <>();
4
+ map .put (0 , 1 );
5
+ for (int i = 0 ; i <= target ; i ++) {
6
+ int sum = 0 ;
7
+ for (int n : nums ) {
8
+ sum += map .getOrDefault (i - n , 0 );
9
+ }
10
+ if (sum != 0 ) {
11
+ map .put (i , sum );
12
+ }
13
+ }
14
+ return map .getOrDefault (target , 0 );
15
+ }
16
+ }
Original file line number Diff line number Diff line change 133
133
- [ 312 Burst Balloons] ( ./312 )
134
134
- [ 337 House Robber III] ( ./337 )
135
135
- [ 341 Flatten Nested List Iterator] ( ./341 )
136
+ - [ 347 Top K Frequent Elements] ( ./347 )
136
137
- [ 349 Intersection of Two Arrays] ( ./349 )
137
138
- [ 350 Intersection of Two Arrays II] ( ./350 )
139
+ - [ 377 Combination Sum IV] ( ./377 )
138
140
- [ 393 UTF-8 Validation] ( ./393 )
139
141
- [ 398 Random Pick Index] ( ./398 )
140
- - [ 347 Top K Frequent Elements] ( ./347 )
141
142
- [ 414 Third Maximum Number] ( ./414 )
142
143
- [ 415 Add Strings] ( ./415 )
143
144
- [ 442 Find All Duplicates in an Array] ( ./442 )
You can’t perform that action at this time.
0 commit comments