Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

have unique vector after sorting vector

vector<int>v ;//ex- v = {7, 3, 8, 3, 2, 8, 8, 5}
sort(v.begin(), v.end()); // v = {2,3,3,5,7,8,8,8}
v.erase(unique(v.begin(), v.end()), v.end());//v= {2, 3, 5, 7, 8}
 
PREVIOUS NEXT
Tagged: #unique #vector #sorting #vector
ADD COMMENT
Topic
Name
3+9 =