Hand of Straights
Return whether all cards can be split into groups of groupSize consecutive integer values. Equal cards are separate occurrences.
Example 1
hand = [1,2,3,2,3,4]
groupSize = 3trueExplanation
Form [1,2,3] and [2,3,4], using every occurrence once.
Example 2
hand = [1,2,4]
groupSize = 3falseExplanation
Missing 3 prevents a consecutive group of size three.
Example 3
hand = [5,5]
groupSize = 1trueExplanation
Every card forms a valid size-one group, even with duplicates.
Constraints
- 1 <= len(hand) <= 10000
- 1 <= groupSize <= len(hand)
- Values are nonnegative integers
Function contract
isNStraightHandArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
[1,2,3,2,3,4]3