+ 1
Who can help me with a code to find duplicates in a vector?
I've always thought of a way to remove the duplicates from a vector, but I found none, can someone help me?
7 Respuestas
+ 6
You may use a temporary set to remove duplicates from your vector:
template<class T>
void RemDuplicates(vector<T>& v)
{
set<T> s;
for(int i=0;i<size;++i)
s.insert(vec[i]);
vec.assign(s.begin(),s.end());
}
+ 10
+ 9
What have you tried?
+ 2
ty
+ 1
but every time i have erors that say that i haven't declare that vector
+ 1
the phase is that I do not have to eliminate them, I have to get them out as an answer
0
i've tried to include another vector that don't have duplicates