Hand of Straights
MediumGreedy
Decode it first. Clues, constraints, pattern and plan before any code.You hold a hand of cards, hand[i] being the value on card i. Decide whether you can split all of the cards into groups of exactly group_size cards, where each group is a run of consecutive values (like 4, 5, 6). Return true or false.
hand = [1, 2, 3, 6, 2, 3, 4, 7, 8], group_size = 3 → true ([1,2,3] [2,3,4] [6,7,8])
hand = [1, 2, 3, 4, 5], group_size = 4 → false (5 cards cannot fill groups of 4)Constraints
1 <= hand.length <= 10^40 <= hand[i] <= 10^91 <= group_size <= hand.length