double findMedianCombine(int A[], int aStart, int aEnd, int B[], int bStart, int bEnd) {

        int[] arr = new int[bEnd + aEnd - aStart - bStart + 2];
        int i = 0;
        while (aStart <= aEnd && bStart <= bEnd) {
            if (A[aStart] < B[bStart]) {
                arr[i] = A[aStart];
                aStart++;
                i++;
            } else {
                arr[i] = B[bStart];
                bStart++;
                i++;
            }
        }

        while (aStart <= aEnd) {
            arr[i] = A[aStart];
            aStart++;
            i++;
        }

        while (bStart <= bEnd) {
            arr[i] = B[bStart];
            bStart++;
            i++;
        }

        return findMedian(arr, 0, arr.length - 1);
    }