Skip to content

Commit fc8591d

Browse files
committed
Create README - LeetHub
1 parent 55e0231 commit fc8591d

File tree

1 file changed

+50
-0
lines changed
  • 1509-minimum-difference-between-largest-and-smallest-value-in-three-moves

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves">1509. Minimum Difference Between Largest and Smallest Value in Three Moves</a></h2><h3>Medium</h3><hr><p>You are given an integer array <code>nums</code>.</p>
2+
3+
<p>In one move, you can choose one element of <code>nums</code> and change it to <strong>any value</strong>.</p>
4+
5+
<p>Return <em>the minimum difference between the largest and smallest value of <code>nums</code> <strong>after performing at most three moves</strong></em>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> nums = [5,3,2,4]
12+
<strong>Output:</strong> 0
13+
<strong>Explanation:</strong> We can make at most 3 moves.
14+
In the first move, change 2 to 3. nums becomes [5,3,3,4].
15+
In the second move, change 4 to 3. nums becomes [5,3,3,3].
16+
In the third move, change 5 to 3. nums becomes [3,3,3,3].
17+
After performing 3 moves, the difference between the minimum and maximum is 3 - 3 = 0.
18+
</pre>
19+
20+
<p><strong class="example">Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> nums = [1,5,0,10,14]
24+
<strong>Output:</strong> 1
25+
<strong>Explanation:</strong> We can make at most 3 moves.
26+
In the first move, change 5 to 0. nums becomes [1,0,0,10,14].
27+
In the second move, change 10 to 0. nums becomes [1,0,0,0,14].
28+
In the third move, change 14 to 1. nums becomes [1,0,0,0,1].
29+
After performing 3 moves, the difference between the minimum and maximum is 1 - 0 = 1.
30+
It can be shown that there is no way to make the difference 0 in 3 moves.</pre>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> nums = [3,100,20]
36+
<strong>Output:</strong> 0
37+
<strong>Explanation:</strong> We can make at most 3 moves.
38+
In the first move, change 100 to 7. nums becomes [3,7,20].
39+
In the second move, change 20 to 7. nums becomes [3,7,7].
40+
In the third move, change 3 to 7. nums becomes [7,7,7].
41+
After performing 3 moves, the difference between the minimum and maximum is 7 - 7 = 0.
42+
</pre>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
49+
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
50+
</ul>

0 commit comments

Comments
 (0)