private int [] mergeAndCountSplitInv(int[] A, int[] B, int size) {
        int [] merged = new int[size];
        int i = 0, j = 0;
        for (int k = 0; k < size; k++) {
            if (i < A.length & j < B.length) {
                if (A[i] < B[j]) {
                    merged[k] = A[i];
                    i++;
                } else if (B[j] < A[i]) {
                    merged[k] = B[j];
                    j++;
                    this.counter += A.length - i;
                }
            } else if (i < A.length) {
                merged[k] = A[i];
                i++;
            } else if (j < B.length) {
                merged[k] = B[j];
                j++;
            }
        }
        return merged;
    }