readings. Two quantities are defined for it:
- the **low** value: the smallest absolute difference between two elements at different indices;
- the **high** value: the largest such difference.
The **score** of the array is low plus high.
You may replace exactly two elements with any integers you like. Return the smallest score you can achieve.readings=[3, 20, 9, 11, 1] → 8
Change 1 and 20 into 9 to get [3, 9, 9, 11, 9]. The smallest gap is 0, the largest is 11 − 3 = 8, so the score is 8.
readings=[7, 50, 2] → 0
Turn 50 and 2 into 7: all values are equal and the score is 0.
readings=[1, 2, 3, 100, 200] → 2
Fixing the two largest values is best: 1, 2 and 3 remain, so the score is 3 − 1 = 2.
readings=[3, 20, 9, 11, 1]
8
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.