欢迎24级新生

2073. LeetCode 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.

输入

nums1 = [1, 3] nums2 = [2]

输出

The median is 2.0

样例

标准输入 复制文本
nums1=[1,2]
nums2=[3,4]
标准输出 复制文本
The median is (2+3)/2=2.5

提示

给定两个⼤⼩为 m 和 n 的有序数组 nums1 和 nums2。 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。

登录以提交代码。
单点时限 1 秒
内存限制 128 MB
提交 0
通过 0