846. Hand of Straights

Practice Hand of Straights for free on NudgeCode: Medium, Greedy pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

hand holds card values. Return true if you can split all the cards into groups of exactly groupSize cards where each group is a run of consecutive values (like [4,5,6]), otherwise false.

Example

hand = [1,2,3,6,2,3,4,7,8], groupSize = 3  ->  true   ([1,2,3],[2,3,4],[6,7,8])
hand = [1,2,3,4,5], groupSize = 4          ->  false

Constraints