public int removeDuplicates(int[] A) {

        if (A.length == 0) return 0;

        int orgIndex = 1;
        int newIndex = 0;

        while(orgIndex < A.length) {
            if (A[newIndex] != A[orgIndex]) {
                A[++newIndex] = A[orgIndex];
            }
            orgIndex++;
        }

        return newIndex+1;
    }