To remove duplicates from a vector, insert all elements into a set: set s(v.begin(), v.end()); automatically removes duplicates and keeps only unique values. Convert back to vector: vector unique(s.begin(), s.end()); gives you a sorted vector with no duplicates.
If you don't need sorting, unordered_set is slightly faster. To preserve original order while deduplicating, use a set to track seen elements while building a new vector. Add only elements that aren't already in the seen set.