Partition Cards into Consecutive Equal-Sized Groups
Quick Overview
Partition Cards into Consecutive Equal-Sized Groups. Use every card in hand exactly once to form groups of groupSize cards, each group containing consecutive integer values.
Partition Cards into Consecutive Equal-Sized Groups
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Other
### Problem
Use every card in hand exactly once to form groups of groupSize cards, each group containing consecutive integer values. Return whether such a rearrangement exists; duplicate card values are separate occurrences.
```cpp
class Solution {
public:
bool isNStraightHand(vector<int>& hand, int groupSize);
};
```
### Examples
**Example 1:**
```text
hand = [0,1,1,2], groupSize = 2
Output: true
Explanation: Form [0,1] and [1,2].
```
**Example 2:**
```text
hand = [1,2,4,5,6,7], groupSize = 3
Output: false
Explanation: The smallest card1 forces a group containing3, which is absent.
```
### Constraints
- Hand size n lies in [1,10000].
- Card values belong to [0,1000000000].
- groupSize lies in [1,n].
### Contract considerations
Use all cards, with exact group sizes and consecutive values.
```hint Read the boundary condition
Where must the smallest remaining value appear within its group?
```
### Boundary reminders
Use all cards, with exact group sizes and consecutive values.
Overview: Partition Cards into Consecutive Equal-Sized Groups. Use every card in hand exactly once to form groups of groupSize cards, each group containing consecutive integer values.
Partition Cards into Consecutive Equal-Sized Groups
Google
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0
Problem
Use every card in hand exactly once to form groups of groupSize cards, each group containing consecutive integer values. Return whether such a rearrangement exists; duplicate card values are separate occurrences.
class Solution {
public:
bool isNStraightHand(vector<int>& hand, int groupSize);
};
Examples
Example 1:
hand = [0,1,1,2], groupSize = 2
Output: true
Explanation: Form [0,1] and [1,2].
Example 2:
hand = [1,2,4,5,6,7], groupSize = 3
Output: false
Explanation: The smallest card1 forces a group containing3, which is absent.
Constraints
Hand size n lies in [1,10000].
Card values belong to [0,1000000000].
groupSize lies in [1,n].
Contract considerations
Use all cards, with exact group sizes and consecutive values.
Boundary reminders
Use all cards, with exact group sizes and consecutive values.