Median of two sorted arrays
Hardbinary searcharraydivide and conquer
a and b are sorted ascending. Return the median of all their elements together; with an even count it's the average of the two middle values. Aim for O(log(m + n)).
Example 1
Input: a = [1,3], b = [2] Output: 2
Example 2
Input: a = [1,2], b = [3,4] Output: 2.5
(2 + 3) / 2 = 2.5.
Constraints
- 0 ≤ m, n ≤ 1000
- 1 ≤ m + n ≤ 2000
- -10⁶ ≤ values ≤ 10⁶
Submit checks your solution against 10 tests, including hidden ones.
/**
* @param {int[]} a
* @param {int[]} b
* @return {double}
*/
function findMedianSortedArrays(a, b) {
}