VradhitV
Reactiflux4y ago
8 replies
Vradhit

Vradhit – 14-13 Jul 30

can anyone please tell me why this telling maximum callstack exceeded in this snippet of leetcode
var permute = function(nums) {
    
    
    let res = [];
    let temp = [];
    backtrack(nums,temp,0);
    return res;
    
    function backtrack(nums,temp,start)
    {
        if(start===nums.length){
            res.push([...temp])
            return;
            
        }
        
        for(let i=0;i<nums.length;i++){
            
            temp.push(nums[i]);
        backtrack(nums,temp,i+1);
            temp.pop();
            
        }
        
        
        
    }
    
    
};
Was this page helpful?