doubleSolution::findMedianSortedArrays(const vector<int> &A, const vector<int> &B){ int n = A.size(), m = B.size(); if(n > m) returnfindMedianSortedArrays(B,A); int l = 0, r = n, med = (n + m) / 2; while(l <= r) { int i = l + (r - l) / 2; int j = med - i; if(i > 0and A[i-1] > B[j]) r = i - 1; elseif(i < n and A[i] < B[j-1]) l = i + 1; else { int r = (i == n) ? B[j] : (j == m) ? A[i] : min(A[i],B[j]); if((n + m) & 1) return r; int l = (i == 0) ? B[j-1] : (j==0) ? A[j-1] : max(A[i-1],B[j-1]); return (l + r) / 2.; } } return-1; }