2022-03-27 20:37:52 +08:00
|
|
|
|
<p>给你个整数数组 <code>arr</code>,其中每个元素都 <strong>不相同</strong>。</p>
|
|
|
|
|
|
|
|
|
|
<p>请你找到所有具有最小绝对差的元素对,并且按升序的顺序返回。</p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>每对元素对 <code>[a,b</code>] 如下:</p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>a , b</code> 均为数组 <code>arr</code> 中的元素</li>
|
|
|
|
|
<li><code>a < b</code></li>
|
|
|
|
|
<li><code>b - a</code> 等于 <code>arr</code> 中任意两个元素的最小绝对差</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
2022-03-27 20:37:52 +08:00
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>arr = [4,2,1,3]
|
2022-03-27 20:37:52 +08:00
|
|
|
|
<strong>输出:</strong>[[1,2],[2,3],[3,4]]
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>arr = [1,3,6,10,15]
|
2022-03-27 20:37:52 +08:00
|
|
|
|
<strong>输出:</strong>[[1,3]]
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 3:</strong></p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>arr = [3,8,-10,23,19,-4,-14,27]
|
2022-03-27 20:37:52 +08:00
|
|
|
|
<strong>输出:</strong>[[-14,-10],[19,23],[23,27]]
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>2 <= arr.length <= 10^5</code></li>
|
|
|
|
|
<li><code>-10^6 <= arr[i] <= 10^6</code></li>
|
|
|
|
|
</ul>
|