```
public int combinationSum4(int[] nums, int target) {
int[] res = new int[target+1];
res[0] = 1;
for(int cur=1; cur<=target; cur++) {
int total = 0;
for(int i=0; i<nums.length; i++) {
if(cur - nums[i] >= 0) {
total += res[cur-nums[i]];
}
}
res[cur] = total;
}
return res[target];
}
```