mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
37 lines
1.1 KiB
HTML
37 lines
1.1 KiB
HTML
<p>给定两个大小分别为 <code>m</code> 和 <code>n</code> 的正序(从小到大)数组 <code>nums1</code> 和 <code>nums2</code>。请你找出并返回这两个正序数组的 <strong>中位数</strong> 。</p>
|
||
|
||
<p>算法的时间复杂度应该为 <code>O(log (m+n))</code> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums1 = [1,3], nums2 = [2]
|
||
<strong>输出:</strong>2.00000
|
||
<strong>解释:</strong>合并数组 = [1,2,3] ,中位数 2
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums1 = [1,2], nums2 = [3,4]
|
||
<strong>输出:</strong>2.50000
|
||
<strong>解释:</strong>合并数组 = [1,2,3,4] ,中位数 (2 + 3) / 2 = 2.5
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>nums1.length == m</code></li>
|
||
<li><code>nums2.length == n</code></li>
|
||
<li><code>0 <= m <= 1000</code></li>
|
||
<li><code>0 <= n <= 1000</code></li>
|
||
<li><code>1 <= m + n <= 2000</code></li>
|
||
<li><code>-10<sup>6</sup> <= nums1[i], nums2[i] <= 10<sup>6</sup></code></li>
|
||
</ul>
|