Median of Two Sorted Arrays
Problem statement
Given two sorted integer arrays nums1 and nums2, return the median of the two arrays as if they were merged.
Your algorithm must run in O(log(min(nums1.length, nums2.length))) time.
Function
findMedianSortedArrays(nums1: int[], nums2: int[]) → doubleExamples
Example 1
nums1 = [1,3]nums2 = [2]return = 2.0The conceptual merged order is [1,2,3], whose middle value is 2.
Example 2
nums1 = [1,2]nums2 = [3,4]return = 2.5The middle values are 2 and 3, so the median is their average.
Constraints
0 <= nums1.length, nums2.length <= 10^5.1 <= nums1.length + nums2.length <= 2 * 10^5.-10^9 <= nums1[i], nums2[i] <= 10^9.- Both arrays are sorted in nondecreasing order.