public static double findMedianSortedArrays(int A[], int B[]) {
		int m = A.length, n = B.length;
		double result = 0;
		if (m > n) return findMedianSortedArrays(B, A);
		int k = (m + n - 1) / 2;
		int left = 0, right = Math.min(m, k);
		while (left < right) {
			int i = (left + right) / 2;
			int j = k - i;
			if (A[i] < B[j]) {
				left = i + 1;
			} else {
				right = i;
			}
		}
		result = Math.max(left > 0 ? A[left - 1] : Integer.MIN_VALUE, k - left >= 0 ? B[k - left] : Integer.MIN_VALUE);
		if (((m + n) & 1) == 1)  return result;
		else result = (result + Math.min(left < m ? A[left] : Integer.MAX_VALUE, k - left + 1 < n ? 
				B[k - left + 1] : Integer.MAX_VALUE)) / 2;
		return result;
	}