Minimum Difference Between Largest and Smallest Value in Three Moves
You are given an integer array nums.
In one move, you can choose one element of nums and change it to any value.
Return the minimum difference between the largest and smallest value of nums after performing at most three moves.
Example 1
Input
nums = [5,3,2,4]Output
0After changing 2, 4, and 5 to 3, all values become 3, so the difference between the minimum and maximum is 0.
Example 2
Input
nums = [1,5,0,10,14]Output
1After three moves the difference can be reduced to 1, and it can be shown that there is no way to make the difference 0 in 3 moves.
Constraints
- 1 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9