spots (all distinct, in no particular order). You must install count sensors, each at its own mounting point.
Sensors interfere when they are close, so place them so that the smallest distance between any two sensors is as large as possible. The distance between points x and y is |x - y|.
Return that largest possible smallest distance.spots=[12, 1, 6, 9, 3], count=3 → 5
Put the sensors at 1, 6 and 12: the gaps are 5 and 6, so the smallest is 5. Nothing better is possible.
spots=[40, 10, 20, 30], count=4 → 10
Every spot is used, and neighbors are 10 apart.
spots=[7, 500000000, 2], count=2 → 499999998
The two sensors go to the outermost spots, 2 and 500000000.
spots) ≤ 10⁵spots[i] ≤ 10⁹spots[i] are distinctcount ≤ len(spots)spots=[12, 1, 6, 9, 3], count=3
5
Run checks the first 3 tests in your browser. Submit checks all 87 tests on the server, hidden ones included.