首先来看题意:
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 |
题目的大意是:给出两个已经排序的数组,求这两个数组组合为一个数组后的中间值。并且要求设计的算法的时间复杂度为O(log (m+n))。