4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
You may assume nums1 and nums2 cannot be both empty.
Example 1:
Example 2:
解题要点:
题目要求时间复杂度为O(log (m+n)),由此我们可以采用归并排序。排好序后,找出中位数。
Previous309. Best Time to Buy and Sell Stock with CooldownNext188. Best Time to Buy and Sell Stock IV
Last updated
Was this helpful?