Class Solution
java.lang.Object
g1501_1600.s1509_minimum_difference_between_largest_and_smallest_value_in_three_moves.Solution
1509 - Minimum Difference Between Largest and Smallest Value in Three Moves.<p>Medium</p>
<p>You are given an integer array <code>nums</code>. In one move, you can choose one element of <code>nums</code> and change it by <strong>any value</strong>.</p>
<p>Return <em>the minimum difference between the largest and smallest value of <code>nums</code> after performing <strong>at most three moves</strong></em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [5,3,2,4]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> Change the array [5,3,2,4] to [<strong>2</strong> , <strong>2</strong> ,2, <strong>2</strong> ]. The difference between the maximum and minimum is 2-2 = 0.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,5,0,10,14]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> Change the array [1,5,0,10,14] to [1, <strong>1</strong> ,0, <strong>1</strong> , <strong>1</strong> ]. The difference between the maximum and minimum is 1-0 = 1.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minDifference
public int minDifference(int[] nums)
-