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)). 这道题让我们求两个有序数组的中位数,而且限制了时间复杂度为O(log (m+n)),看到这个时间复杂度,自然而然的想到了应该使用二分查找法来求解.但是这道题
4. 寻找两个有序数组的中位数 https://leetcode-cn.com/problems/median-of-two-sorted-arrays/ 最简单的就是用最简单的,把两个数组分别抽出然后排成一个排好序的数组,然后根据中位数的定义,直接根据中间的索引值得到中位数的值. 如果上面这么说明有些抽象的话,我们来看看代码: Show the Code. class Solution { public double findMedianSortedArrays(int[] nums1, in