Help! JavaScript Time Limit Exceeded


  • 0
    X
    var combinationSum4 = function(nums, target) {
        var count = 0;
        for(var i = 0; i < nums.length  && target > 0; i++){
            if(nums[i] > target) continue;
            count += combinationSum4(nums,target - nums[i]);
            
        }
        if(target === 0 ){
            count++;
        }
        return count;
    };
    

    Help! Time Limit Exceeded when nums = [1,2,3], target = 32;


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.