Problem
You have some cards. The integer array hand holds the value of each card. You also get an integer group_size.
Put all the cards into groups. Each group must have exactly group_size cards with consecutive values. Consecutive values increase by 1 from one card to the next, for example 5, 6, 7.
Each card is in exactly one group. Return true if you can make the groups. Otherwise, return false.
Example 1
- Input:
- hand = [4,2,3,3,5,4], group_size = 3
- Output:
- true
- Explanation:
- Make the groups
[2, 3, 4]and[3, 4, 5].
Example 2
- Input:
- hand = [1,2,3,5,6,7,8], group_size = 2
- Output:
- false
- Explanation:
- The hand has 7 cards. You cannot put 7 cards into groups of 2.
Example 3
- Input:
- hand = [1,1,2,3], group_size = 2
- Output:
- false
- Explanation:
- The hand has two cards with the value 1, so two groups must start with 1. Each of these groups needs a 2, but the hand has only one 2.
Constraints
- 1 <= hand.length <= 10^4
- 0 <= hand[i] <= 10^9
- 1 <= group_size <= hand.length
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 846. Hand of Straights
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source