Why this solution is not working?


#1
int n=A.size();
int count = 0;
int j=1;
for(int i=0;j<n;i++){
    while(A[i]==A[j]){
        j++;
        count++;
    }
    A[i+1]=A[j];
    j++;
}
return n-count;