Median of Two Sorted Lists
Return the median of the combined values of two sorted lists a and b as a float. At least one list is non-empty.
Requirements
- Run in time by binary searching a partition.
Examples
EXAMPLE WALKTHROUGHodd total
A guided view of the published example, not a trace of your code.
INPUT
[[1,3],[2]]TASKmedian_of_two_sorted()
EXPECTED OUTPUT
2Start with the input values shown in this example.
Example 1 of 3
Input: a = [1,3], b = [2]
Output: 2
Explanation: odd total
Input: a = [1,2], b = [3,4]
Output: 2.5
Explanation: even total
Input: a = [], b = [1]
Output: 1
Explanation: one empty
Hint 1
Partition both lists so the left halves together hold half the elements.
Hint 2
A partition is correct when max(left parts) ≤ min(right parts).