values and an integer reach. Each element may be replaced at most once by any integer in the range [values[i] - reach, values[i] + reach].
After the replacements, pick as many elements as possible (from any positions) that are all equal. Return the largest possible number of such elements.values=[3, 11, 8, 15], reach=2 → 2
8 and 11 can both become 10 (or 9), but no three can be made equal: 8 and 15 differ by 7, more than 2 · 2. The answer is 2.
values=[1, 10, 4, 7], reach=3 → 3
Turn 1, 4 and 7 into 4: shift the first by +3 and the third by -3. The 10 cannot reach them.
values=[6], reach=0 → 1
values=[3, 11, 8, 15], reach=2
2
Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.