Group the People Given the Group Size They Belong To
A medium-tier problem at 87% community acceptance, tagged with Array, Hash Table, Greedy. Reported in interviews at Roblox and 0 others.
You've got a list of group sizes, and you need to reconstruct which people belong to which group. It sounds simple until you realize you can't just sort and split. This problem hits the sweet spot where the greedy approach isn't obvious on first read, and that's why Roblox has asked it. With an 87% acceptance rate, most people who see it solve it, but plenty blank on the pattern during a live OA. If you freeze on the greedy logic, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Group the People Given the Group Size They Belong To"
Group the People Given the Group Size They Belong To is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.
Get StealthCoderThe trick is backward iteration. You iterate from the largest group size down to the smallest, assigning people greedily without ever second-guessing. At each step, you grab the next unused person and assign them to a group of the declared size. The pitfall: trying to validate or rearrange after assignment, or thinking you need to match group sizes exactly upfront. Most candidates over-engineer this. The greedy choice works because once you've placed a group of size K, those K people are locked in, and you move to the next unplaced person. Hash tables track which group each person belongs to, arrays track which people are unassigned. When the pattern clicks, the code is short. StealthCoder's value here is catching the moment you start down the wrong path during the assessment and handing you the correct logic.
Pattern tags
You know the problem.
Make sure you actually pass it.
Group the People Given the Group Size They Belong To recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Group the People Given the Group Size They Belong To interview FAQ
Why does backward iteration matter?+
Forward iteration can trap you into invalid assignments because you don't know future group size demands. Backward iteration lets you place the largest groups first on the largest available pool of unassigned people, guaranteeing no conflicts. It's a greedy choice that always succeeds.
Is this still asked at real companies?+
Roblox has confirmed it. The 87% acceptance rate suggests it's in active rotation, not archived. It's not a flagship FAANG question, but it appears in medium-tier interview loops at gaming and backend companies.
What's the relationship between Hash Table and Greedy here?+
Hash Table stores the mapping of person to group ID. Greedy is the algorithm: pick the next unassigned person, place them into a group of the required size, lock it in, move on. The two topics work together, not in isolation.
How do you avoid the off-by-one trap?+
Track your unassigned pool carefully. After assigning K people to a group, your unassigned pool shrinks by K. Backward iteration over group sizes ensures you always have enough unassigned people left. Test with the edge case where all people have group size 1.
Why isn't this easy if acceptance rate is 87%?+
High acceptance rate doesn't mean the pattern is intuitive. It means people who study it get it. In a live OA, under time pressure, the backward greedy logic isn't the first thing you'll try. That's where blanking happens.
Want the actual problem statement? View "Group the People Given the Group Size They Belong To" on LeetCode →