tiles[i] is the number on tile i. You must lay out all of them in rows of exactly size tiles so that the numbers in each row are consecutive: x, x + 1, …, x + size - 1. Every tile goes into exactly one row.
Return True if such a layout exists and False otherwise.tiles=[5, 3, 4, 6, 4, 5], size=3 → True
The tiles form the runs [3, 4, 5] and [4, 5, 6].
tiles=[1, 2, 4, 5], size=2 → True
The runs [1, 2] and [4, 5] work: numbers must be consecutive within a run, but separate runs are unrelated.
tiles=[2, 2, 3, 4], size=2 → False
One 2 has to pair with the 3, and the other would need a 1 or a 3: there is no 1, and the 3 is taken.
size ≤ len(tiles) ≤ 10⁵tiles=[5, 3, 4, 6, 4, 5], size=3
True
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.