public int removeDuplicates(int[] A) {
        if(A == null || A.length == 0) return 0;
        int l = 0, pre = -1;
        for(int cur = 0; cur < A.length; cur++) {
            if(pre == -1 || A[cur] != A[pre]) {
                pre = cur;
                A[l++] = A[cur];
            } 
        }
        return l;
    }