1 class Solution { 2 public int combinationSum4(int[] nums, int target) { 3 int[] res = new int[target + 1]; 4 res[0] = 1; 5 for(int i = 1; i <= target; i++) { 6 for(int j = 0; j < nums.length; j++) { 7 if(nums[j] <= i && res[i - nums[j]] > 0) { 8 res[i] += res[i - nums[j]] ; 9 }10 }11 }12 return res[target];13 14 15 }16 }