mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<p>给你一个数组 <code>nums</code> ,每次操作你可以选择 <code>nums</code> 中的任意一个元素并将它改成任意值。</p>
|
||
|
||
<p>请你返回三次操作后, <code>nums</code> 中最大值与最小值的差的最小值。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [5,3,2,4]
|
||
<strong>输出:</strong>0
|
||
<strong>解释:</strong>将数组 [5,3,2,4] 变成 [<strong>2</strong>,<strong>2</strong>,2,<strong>2</strong>].
|
||
最大值与最小值的差为 2-2 = 0 。</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,5,0,10,14]
|
||
<strong>输出:</strong>1
|
||
<strong>解释:</strong>将数组 [1,5,0,10,14] 变成 [1,<strong>1</strong>,0,<strong>1</strong>,<strong>1</strong>] 。
|
||
最大值与最小值的差为 1-0 = 1 。
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [6,6,0,1,1,4,6]
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p><strong>示例 4:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,5,6,14,15]
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 10^5</code></li>
|
||
<li><code>-10^9 <= nums[i] <= 10^9</code></li>
|
||
</ul>
|