Solution similiar to remove-element.

    int removeDuplicates(int A[], int n) {
        // IMPORTANT: Please reset any member data you declared, as
        // the same Solution instance will be reused for each test case.
        
        if(n == 0) return 0;
        
        int lc = 0, prev = A[0];
        
        for(int i = 1 ; i < n ; i++){
            if(prev == A[i]){
                lc++;
            } else{
                prev = A[i];
            }
            
            A[i-lc] = A[i];
        }
        return n-lc;
    }