Why TLE with O(n^2) iterative sol?


#1
void possible(vector<vector<int>> &res,vector<int> q,int n){
	vector<int> tmp;
	int t=res.size();
	for(int i=0;i<t;i++){
	    tmp=res[0];
	    res.erase(res.begin()+0);
	    if(tmp.size()>1){
	        res.push_back(tmp);
	    }
	    tmp.push_back(q[n]);
		res.push_back(tmp);
	}
	for(int i=0;i<=n;i++){
	    tmp.clear();
	    tmp.push_back(q[i]);
		res.push_back(tmp);
	}
	return ;
}

vector<vector<int> > Solution::subsets(vector<int> &A) {
    vector<vector<int>> res;
    vector<int> tmp;
    if(A.size()<1){
        tmp.clear();
        res.clear();
        res.push_back(tmp);
        return res;
    }
    sort(A.begin(),A.end());
    tmp.push_back(A[0]);
    res.push_back(tmp);
    int n=A.size();
    for(int i=1;i<n;i++)
        possible(res,A,i);
    tmp.clear();
    res.push_back(tmp);
    sort(res.begin(),res.end());
    return res;
}