ratings, whose length is a multiple of 3. The coach wants the ratings of any two players on the same team to differ by at most spread.
Return the split as a list of trios. If several splits work, return the lexicographically smallest one: ratings inside each trio go in increasing order, and the trios are ordered increasingly as lists. If no such split exists, return an empty list.ratings=[10, 4, 6, 12, 5, 11], spread=2 → [[4, 5, 6], [10, 11, 12]]
The trios [4, 5, 6] and [10, 11, 12] each have a spread of 2.
ratings=[3, 3, 3, 3, 9, 9], spread=5 → []
Four 3s cannot fit into one trio, so some 3 ends up with a 9, and the gap of 6 exceeds 5.
ratings=[7, 1, 4], spread=6 → [[1, 4, 7]]
spread ≤ 10⁵ratings=[10, 4, 6, 12, 5, 11], spread=2
[[4, 5, 6], [10, 11, 12]]
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.