Simpler shorter c++


  • 0
    L
     int combinationSum4(vector<int>& nums, int target) {  
                res = vector<int>(target+1, 0);
                res[0] = 1;
                for( int t=1; t <= target; t++)    
                    for( int num: nums) {
                        if( t - num >= 0)
                            res[t] += res[t-num];
                    }
                return res[target];
                
        }
    

Log in to reply
 

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