← Roblox Interview Insights

Roblox·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Roblox coding round with one meaty grid simulation problem. Two phases to implement, which sounds manageable until you're actually in it trying to keep track of what counts as a run and then simulating gravity correctly.

Questions Asked (1)

Q1

Given an m x n grid of single digits, first find all horizontal or vertical consecutive runs of the same digit with length 3 or more, returning each as [row, col, length] sorted top-to-bottom then left-to-right. Then remove all cells belonging to those runs, let the remaining digits fall down within their columns, and fill the top with zeros. Return the final grid.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The two-phase structure is what gets you.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then propose a two-phase solution: first scan the grid to identify all runs of length >= 3, then mark those cells for removal and apply gravity column-wise. Discuss time/space complexity and potential optimizations, such as using a visited array or processing runs in a single pass.

Pro tip: Mention that you would handle overlapping runs carefully—a cell can belong to both a horizontal and vertical run—and ensure it's only removed once. Also, consider using a boolean matrix to mark removed cells to avoid modifying the grid during the scan.

1. Clarify requirements and edge cases

Ask about grid size limits, whether runs can overlap, and if the output should be sorted as specified. Confirm that after removal, digits fall down and zeros fill the top.

2. Identify all runs

Scan each row for horizontal runs and each column for vertical runs of the same digit with length >= 3. Record each run as [row, col, length] and sort them as required.

3. Mark cells for removal

Use a boolean matrix to mark all cells that belong to any identified run. This handles overlaps and ensures each cell is removed only once.

4. Apply gravity and fill zeros

For each column, collect the remaining digits from bottom to top, then place them at the bottom of the column and fill the top with zeros.

5. Analyze complexity and trade-offs

Discuss time complexity O(m*n) for scanning and gravity, and space complexity O(m*n) for the boolean matrix. Mention potential optimizations like in-place marking or using a queue for runs.

Key Points to Mention

  • Two-phase approach: identify runs then apply gravity
  • Handling overlapping runs with a boolean removal matrix
  • Sorting runs by row then column as specified
  • Column-wise gravity implementation using a write pointer
  • Time and space complexity analysis
  • Edge cases: no runs, full grid removal, single row/column

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.