```
public int combinationSum4(int[] nums, int target) {
if (target == 0 || nums.length == 0) {
return 0;
}
Arrays.sort(nums);
int[] M = new int[target + 1];
M[0] = 1;
for(int n = 1; n <= target; n++) {
for(int num : nums) {
if(n < num) {
break;
}
M[n] += M[n - num];
}
}
return M[target];
}
```