A simple two pointer code in c++;


#1

Comment body goes here.int Solution::removeDuplicates(vector &A) {
int n=A.size();
if(n<=2)
return n;
int left=2;
for(int right=2;right<n;right++)
{
if(A[left-2]!=A[right])
A[left++]=A[right];
}
return left;
}