values of length n. Call it **solid** if all its numbers are distinct and, once sorted, they follow one another with no gaps, meaning the maximum minus the minimum equals n - 1. For example, [6, 4, 5, 7] is solid and [1, 2, 4] is not.
In one operation you may replace any element with any integer. Return the smallest number of operations that makes the array solid.values=[3, 8, 4, 4, 6] → 2
Replace the second 4 with 5 and the 8 with 7: you get [3, 7, 4, 5, 6], the numbers 3 through 7 with no repeats.
values=[1, 100, 200] → 2
Any two of the three numbers are too far apart, so only one can stay.
values=[10] → 0
values=[3, 8, 4, 4, 6]
2
Run checks the first 3 tests in your browser. Submit checks all 134 tests on the server, hidden ones included.