Google OA
Min Amplitude
FULLTIME
Given an Array A, find the minimum amplitude you can get after changing up to 3 elements. Amplitude is the range of the array (basically difference between largest and smallest element).
Example 1 :
Input: A = [-1, 3, -1, 8, 5, 4]
Output:
2
Explanation:
We can change -1, -1, 8 to 3, 4 or 5.
Example 2 :
Input:
A = [10, 10, 3, 4, 10]
Output:
0
Explanation:
Change 3 and 4 to 10.
