ratings, and exactly matches games must be played. Each game pairs two different players, and nobody plays more than one game. Some players may sit out.
The gap of a game is the absolute difference between its two players' ratings. The organizer wants even the most lopsided game to be as close as possible.
Return the smallest possible value of the largest gap across all matches games. If matches is 0, the answer is 0.ratings=[15, 4, 9, 12, 5, 20], matches=2 → 3
Pair 4 with 5 (gap 1) and 9 with 12 (gap 3). The worse of the two gaps is 3, and nothing beats that.
ratings=[8, 3, 8], matches=1 → 0
Match the two players rated 8: the gap is 0.
ratings=[1, 100], matches=0 → 0
No matches are needed, and the worst gap over an empty set counts as 0.
ratings=[15, 4, 9, 12, 5, 20], matches=2
3
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.