Split Story Frame Numbers Into Runs of Consecutive Frames

Last updated: November 29, 2026

Quick Overview

Given a multiset of Story frame numbers and a group size w, split them into groups of w consecutive numbers each, or return an empty list if that is impossible.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given a multiset of Story frame numbers and a group size w, split them into groups of w consecutive numbers each, or return an empty list if that is impossible.

A Meta technical-screen greedy question that relies on ordered keys. The interviewer looks for the observation that the smallest remaining number must start a group, and for an efficient walk over sorted distinct keys rather than repeatedly removing from a list.

What the Interviewer Expects
  • Reject when the count is not divisible by w
  • Count occurrences per frame number
  • Process distinct keys in ascending order
  • Start as many runs at a key as its remaining count
  • Fail when a needed successor is short
Key Topics to Cover
greedy
ordered map
counting
sorting
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return only True or False with O(n log n) and minimal memory.
  • What if gaps of one missing frame are allowed in a run?
  • What if group sizes may vary between w and 2w?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of integers (may repeat), group size w >= 1.
  • Output: list of groups, each [x, x + 1, ..., x + w - 1], using every number exactly once; [] if impossible....
High-Level Design

The smallest remaining number cannot be in the middle of any group (nothing smaller is left to precede it), so it must start a group. That forces the greedy:

  1. Count each number.
  2. Walk distinc...

Submit Your Answer
Markdown supported