If the input: int[] nums= [1,2,3], target=4; why the output res=0; the res has not been accumulated?
public int combinationSum4(int[] nums, int target) {
int res=0;
helper(nums,target,res);
return res;
}
private void helper(int[] nums, int target, int res){
if (target==0) {
res++;
return;
}
else if (target<0) return;
else {
for(int i=0;i<nums.length;i++){
helper(nums, target-nums[i],res);
}
}
}