FreeCareerPath
Build the PrimitiveHard

Median of Two Sorted Arrays

Write `find_median_sorted_arrays(a, b)` returning the median of the two ascending arrays combined, as a float. find_median_sorted_arrays([1, 3], [2]) -> 2.0 find_median_sorted_arrays([1, 2], [3, 4]) -> 2.5 Merging is O(m + n) and is worth stating before you discard it. The real answer searches for a *partition*: cut both arrays so the left side holds exactly half the elements and every value on the left is at most every value on the right. Search the shorter array to bound the work, and use infinities for the out-of-range edges so the empty-side cases need no special handling.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Median of Two Sorted Arrays" are saved to your account — logging in takes a few seconds.

Median of Two Sorted Arrays — FreeCareerPath