Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
Example 1:
The overall run time complexity should be O(log (m+n)) (Disregard this for the purposes of this question)
Input: nums1 = [1,3], nums2 = [2]
Output: 2.00000
Explanation: merged array = [1,2,3] and median is 2.Leetcode
Solution
- The median is defined as the kth smallest element, where k is equal to len/2 + 1 if the length is odd, and k = len/2 if the length is even.
- Code