Bad validator : expect orderer list on return


#1

The problem statment says
4. The list must not be sorted

However, the validator thinks different

Your submission failed for the following input:A : [ 12, 13 ]

Your function returned the following : [] [12 13 ] [12 ] [13 ]

The expected returned value :[] [12 ] [12 13 ] [13 ]

BTW:

  1. Also, the subsets should be sorted in ascending ( lexicographic ) order.

In theory sets have no order.


#2

Can you help why my code is giving output only []

void sub_rec(vector &A,int index,vector<vector> &ans)
{
if(index = A.size())return;
vector temp;
if(index != 0)temp=ans[ans.size()-1];
for(int i=index;i<A.size();i++){
temp.push_back(A[i]);
ans.push_back(temp);
sub_rec(A,i+1,ans);
temp.pop_back();
}
return;
}

vector<vector > Solution::subsets(vector &A) {
sort(A.begin(),A.end());
vector<vector> ans{{}};
int index=0;
sub_rec(A,index,ans);
return ans;
}