values. A stretch is a run of consecutive readings. A stretch is tight if the difference between its largest and smallest reading is at most spread.
Return the length of the longest tight stretch. A single reading is always a tight stretch.values=[5, 9, 6, 8, 2, 3], spread=3 → 3
The stretch 9, 6, 8 has maximum 9 and minimum 6, a difference of exactly 3. No four consecutive values stay within 3.
values=[7, 7, 7, 1], spread=0 → 3
With spread = 0 all values in the stretch must be equal: the three 7s in a row.
values=[5, 9, 6, 8, 2, 3], spread=3
3
Run checks the first 3 tests in your browser. Submit checks all 180 tests on the server, hidden ones included.