1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数组列表中的最大距离 [maximum-distance-in-arrays].html

37 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定&nbsp;<code>m</code>&nbsp;个数组,每个数组都已经按照升序排好序了。</p>
<p>现在你需要从两个不同的数组中选择两个整数(每个数组选一个)并且计算它们的距离。两个整数&nbsp;<code>a</code>&nbsp;&nbsp;<code>b</code>&nbsp;之间的距离定义为它们差的绝对值&nbsp;<code>|a-b|</code>&nbsp;</p>
<p>返回最大距离。</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>[[1,2,3],[4,5],[1,2,3]]
<strong>输出:</strong>4
<strong>解释:</strong>
一种得到答案 4 的方法是从第一个数组或者第三个数组中选择 1同时从第二个数组中选择 5 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>arrays = [[1],[1]]
<b>输出:</b>0
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == arrays.length</code></li>
<li><code>2 &lt;= m &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= arrays[i].length &lt;= 500</code></li>
<li><code>-10<sup>4</sup> &lt;= arrays[i][j] &lt;= 10<sup>4</sup></code></li>
<li><code>arrays[i]</code>&nbsp;&nbsp;<strong>升序</strong>&nbsp;排序。</li>
<li>所有数组中最多有&nbsp;<code>10<sup>5</sup></code> 个整数。</li>
</ul>
<p>&nbsp;</p>