本帖最后由 Miss_Allsunday 于 2017-6-17 08:27 编辑
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)). Example 1:
nums1 = [1, 3]nums2 = [2]The median is 2.0
Example 2:
nums1 = [1, 2]nums2 = [3, 4]The median is (2 + 3)/2 = 2.5有两个排好序的数组nums1和nums2,各自是有m和n的大小。
找出两个数组的中位数,总共的运行复杂度应为O(log(m+n)).
举例:
nums1 = [1, 3]
nums2 = [2]
中位数 是 2.0
nums1 = [1, 2]
nums2 = [3, 4]
中位数是 (2 + 3)/2 = 2.5
你需要完成以下的函数:
double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size) {
}
这道题目的网址是:“https://leetcode.com/problems/median-of-two-sorted-arrays/#/description”
|