Why it is returning 0 0 on testcase 1 0


#1

int Solution::removeDuplicates(vector &a) {

int i=0;
int j=0;
int n=a.size();

for(i=0;i<n;)
{
    if(a[i]==a[i+1]&&a[i]==a[i+2])
    {
        a[j++]=a[i];
        a[j++]=a[i];
        i+=2;
        
    }
    else  if(a[i]!=a[i+1])
    {
      a[j++]=a[i];
      i+=1;
    }
    else
    i++;
}
return j;

}


#2

1 0 is invalid input as array is supposed to be sorted