Class Solution
- java.lang.Object
-
- g1501_1600.s1509_minimum_difference_between_largest_and_smallest_value_in_three_moves.Solution
-
public class Solution extends Object
1509 - Minimum Difference Between Largest and Smallest Value in Three Moves.Medium
You are given an integer array
nums. In one move, you can choose one element ofnumsand change it by any value.Return the minimum difference between the largest and smallest value of
numsafter performing at most three moves.Example 1:
Input: nums = [5,3,2,4]
Output: 0
Explanation: Change the array [5,3,2,4] to [2 , 2 ,2, 2 ]. The difference between the maximum and minimum is 2-2 = 0.
Example 2:
Input: nums = [1,5,0,10,14]
Output: 1
Explanation: Change the array [1,5,0,10,14] to [1, 1 ,0, 1 , 1 ]. The difference between the maximum and minimum is 1-0 = 1.
Constraints:
1 <= nums.length <= 105-109 <= nums[i] <= 109
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intminDifference(int[] nums)
-