cards[i] is the number on card i. Several cards may show the same number.
You need to split all the cards into sets of exactly size cards so that each set holds consecutive numbers: x, x + 1, …, x + size - 1. Every card must go into exactly one set.
Return True if such a split is possible and False otherwise.cards=[5, 3, 4, 4, 6, 5], size=3 → True
The cards split into the sets [3, 4, 5] and [4, 5, 6].
cards=[1, 2, 4, 5], size=2 → True
[1, 2] and [4, 5] work: each set holds consecutive values.
cards=[2, 3, 3, 4], size=2 → True
The 2 can only go with a 3, which leaves 3 and 4, also a valid set. The answer is True.
cards=[5, 3, 4, 4, 6, 5], size=3
True
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.