public static int removeDuplicates2(int[] A) {//passed after consulting answer
        if (A.length < 2) return A.length;
        int len = A.length;
        int i = 1;
        int j = 1;
        while (j < len) {
            if (A[j] > A[i-1]) {
                A[i] = A[j];
                ++i;
                j = i;
            }
            else {
                ++j;
            }
        }
        System.out.println(i);
        return i;
    }