I'll show you how to eliminate duplicate values from a vector. First, sort the vector with sort(v.begin(), v.end()) to group identical elements together. Then call auto it = unique(v.begin(), v.end()) which shifts duplicates to the end and returns an iterator to the new logical end.
Finally, erase the garbage with v.erase(it, v.end()). The unique function only removes consecutive duplicates, which is why you sort first. Without sorting, unique misses duplicates that aren't adjacent.
This modifies the original vector, so copy it first if you need both versions.