Closed congr closed 5 years ago
class Solution {
public int combinationSum4(int[] nums, int target) {
int[] D = new int[target+1];
D[0] = 1;
for (int s = 0; s <= target; s++) {
for (int i = 0; i < nums.length; i++) {
if (s - nums[i] >= 0)
D[s] += D[s - nums[i]];
}
}
return D[target];
}
}
https://leetcode.com/problems/combination-sum-iv/