Median of Two Sorted Arrays

Hard
ArrayBinary SearchDivide and ConquerGoogleAmazon
Given two sorted arrays, print the median of all the numbers combined. The median is a multiple of 0.5: print it as a whole number when it is an integer, otherwise print it with exactly one digit after the decimal point (for example `2.5`). Input format: - First line: m n - Second line: m integers in ascending order (may be blank when m is 0) - Third line: n integers in ascending order (may be blank when n is 0)

Constraints

0 <= m, n
1 <= m + n <= 2 * 10^5
-10^6 <= values <= 10^6
Each array is sorted ascending.

Sample tests

Sample 1

Sample 2

Sign in to submit