4. Median of Two Sorted Arrays
# Hard
Last updated
Was this helpful?
# Hard
Last updated
Was this helpful?
Compare the len(nums1)/2
th and len(nums2)/2
th element, increase or decrease the position based on different situations. Very hard. Give up temporary. Time complexity is
Think about it as finding the k
th element in two sorted array. Compare thek/2
th element in nums1
and k/2
th element in nums2
, then throw k/2
element. This algorithm uses iteration with binary search. Its time complexity is