Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

combination sum iv leetcode

public int combinationSum4(int[] nums, int target) {
    if (target == 0) {
        return 1;
    }
    int res = 0;
    for (int i = 0; i < nums.length; i++) {
        if (target >= nums[i]) {
            res += combinationSum4(nums, target - nums[i]);
        }
    }
    return res;
}
Source by massivealgorithms.blogspot.com #
 
PREVIOUS NEXT
Tagged: #combination #sum #iv #leetcode
ADD COMMENT
Topic
Name
3+9 =