This is my best one, but somebody explain why it got only partial points


#1

int Solution::removeDuplicates(vector &A) {

int i=0;
while(i<A.size()-2)
{
if(A[i]==A[i+1])
{
A.erase(A.begin()+i);
}
else
{
i++;

}

}
return A.size();

}


#2

This is “Two Pointers” section. So you might want try to divide original list in two sections using two pointers. First section would be with unique elements, second section would be with not yet processed elements. While you go through an array you move to the first section only unique elements from the second section. At the end you’ll need to truncate the array to the length of the first section. Your approach works just fine, but if the input array is big and has a lot of duplicate items this approach works much faster.