Why is my answer "Memory Limit Exceed"


  • 0
    H

    class Solution {
    public:
    void recur(vector<vector<int> >&res, vector<int> &sub, int subNum, vector<int>&S)
    {

            for(int j=subNum;j<S.size();j++)
            {
                sub.push_back(S[j]);
                res.push_back(sub);
                if (j<S.size()-1) 
                     recur(res, sub, subNum+1, S);
                sub.pop_back();
            }
    }
    vector<vector<int> > subsets(vector<int> &S) {
        vector<vector<int> > res;
        vector<int> sub;
        if(S.size()==0) return res;
        res.push_back(sub);
        sort(S.begin(),S.end());
        
        recur(res, sub, 0,S);
        return res;
    }
    

    };

    Anybody can find mistakes for me?


Log in to reply
 

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