readings. You may fix at most three of them: each fix replaces one reading with any integer you like.
The spread of the series is its largest value minus its smallest value. Return the smallest spread you can achieve.readings=[12, 40, 7, 9, 100, 11] → 3
Edit 7, 40 and 100, say to 10. The values then run from 9 to 12, a spread of 3.
readings=[5, -5, 0] → 0
There are only three values, so all of them can be made equal.
readings=[1, 2, 3, 4, 5, 6, 7] → 3
However the three edits are spent, four consecutive values survive, so the spread is at least 3.
readings=[12, 40, 7, 9, 100, 11]
3
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.