public int removeDuplicates(int[] A) {
            assert A != null;
            if (A.length == 0) {
                return 0;
            }
            int len = 1;
            for (int i = 1; i < A.length; i++) {
                if (A[len - 1] != A[i]) {
                    A[len++] = A[i];
                }
            }
            return len;
        }