Minimum Difference Between Largest and Smallest Value in Three Moves
You are given an integer array nums. In one move you can change any one element to any value. Return the minimum possible difference between the largest and smallest value of nums after at most three moves.
30:00
Minimum Difference Between Largest and Smallest Value in Three Moves
You are given an integer array nums. In one move you can change any one element to any value. Return the minimum possible difference between the largest and smallest value of nums after at most three moves.
Example 1:
Input: {"nums":[5,3,2,4]}
Output: 0
Constraints:
1≤nums.length≤105
−109≤nums[i]≤109
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[5,3,2,4]}
4 numbers. Three moves can rewrite three elements to anything, so the question is which three to give up.