Hand of Straights
Implement isNStraightHand
You're holding a hand of cards, each showing an integer, and want to split them into groups where every group has exactly groupSize cards forming a run of consecutive integers, with no repeats inside a single group.
Determine whether such a split is possible using every card in the hand exactly once.
Example 1:
Input: hand = [5,6,7,5,6,7], groupSize = 3
Output: true
Example 2:
Input: hand = [9,10,11,12], groupSize = 3
Output: false
Example 3:
Input: hand = [2,2,3,3,4,4], groupSize = 2
Output: false
+ 6 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ hand.length ≤ 40 - ●
-100 ≤ hand[i] ≤ 100 - ●
1 ≤ groupSize ≤ hand.length
hand =
[5, 6, 7, 5, 6, 7]
groupSize =
3