You are given two sorted lists, nums1 (with m numbers) and nums2 (with n numbers). Return the median of all the numbers from both lists together.
The median is the middle value when all numbers are sorted. If the count is even, the median is the average of the two middle values. Your solution should take O(log (m+n)) time.
Examples
Example 1:
Input: nums1 = [2,4], nums2 = [1,3,5]
Output: 3.00000
Explanation: All numbers sorted: 1, 2, 3, 4, 5. The middle one is 3.
Example 2:
Input: nums1 = [5,6], nums2 = [1,2]
Output: 3.50000
Explanation: All numbers sorted: 1, 2, 5, 6. The median is (2 + 5) / 2 = 3.5.
Example 3:
Input: nums1 = [], nums2 = [9]
Output: 9.00000
Explanation: Only one number, 9.