It can be done in O(n)

```
void dedup(vector<int> &v)
{
int i = 0;
for(int j = 1; j < v.size(); ++j)
{
if(i != j)
{
if(v[i] != v[j])
{
v[++i] = v[j];
}
}
}
v.resize(i+1);
}
```