```
public static int combinationSum4(int[] nums, int target) {
int[] memo = new int[target+1];
Arrays.sort(nums);
for(int i = 1; i <= target; i++)
for(int j = 0; j < nums.length; j++) {
if (i < nums[j]) break;
if(nums[j] == i) memo[i] += 1;
else memo[i] += memo[i-nums[j]];
}
return memo[target];
}
```