Test cases not run

how to make my vector<vector> only only unique combinations…

Hi @dakshi,
u can use vector inbuilt unique function.
it can be used as follows
vector v = { 1, 1, 3, 3, 3, 10, 1, 3, 3, 7, 7, 8 }, i;

vector<int>::iterator it; 

// Using std::unique 
it = std::unique(v.begin(), v.end()); 
// Now v becomes {1 3 10 1 3 7 8 * * } 
// * means undefined 
// Resize the vector so as to remove the undefined terms 
v.resize(std::distance(v.begin(), it));  

also make sure that u sort the vector first as unique only removes consecutive duplicate elements.
Or u can can use set<vector> as set store only unique elements.
Hope dis helps.

i have vector<vector> to store my combinations…
how to use set here? or even the unique function in this case

@dakshi,
if u r going to use vector<vector> ,make sure all the vectors inside are sorted. so befor applying unique, sort the vector(containing all other vector) and use
vector::iterator it;
it = std::unique(v.begin(), v.end());
v.resize(std::distance(v.begin(), it));

else, u can use set
use s.insert(v) to insert vector in set

to print set use,
set<vector> :: iterator it;
for(it=s.begin();it!=s.end();it++){
vector v2=*it;
for(int i=0;i<v2.size();i++){
cout<<v2[i]<<" ";
}
cout<<endl;
}

Hope dis helps

@dakshi
pls refer to dis code to understand use of set in dis question better

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.