FastPrepBounds of Every Zero Rectangle
Problems/Bounds of Every Zero Rectangle

Bounds of Every Zero Rectangle

Roblox logoRoblox● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Roblox phone screen. The reported zero-rectangle task matches at about 90%. We chose these: zeros that touch on four sides form one group, groups separated by an edge are different, results come in a fixed order, corners are written as a flat list, there is a result for a grid with no zeros, and the numbers have limits.

Given a nonempty rectangular integer matrix matrix containing only 0 and 1, return the bounds of every zero rectangle.

For this exercise, assume every group of zeros connected through immediately adjacent up, down, left or right cells is a completely filled rectangle whose sides follow the matrix rows and columns. Separate rectangles never touch along an edge; they may touch diagonally. There may be no zero rectangle. Arbitrary shapes and overlapping rectangle decompositions are outside this valid-input contract.

For this exercise, assume coordinates are zero-based and both endpoints are inclusive. Return one row [top,left,bottom,right] per rectangle, ordered by its top-left row and then column. This four-integer row encodes the two corner coordinates. An input with no zeros returns an empty matrix.

Function

allRectangleBounds(matrix: int[][]) → int[][]

Examples

Example 1

matrix = [[0,1,1,1],[1,0,0,1],[1,0,0,1],[1,1,1,1]]return = [[0,0,0,0],[1,1,2,2]]
matrix
012300111110012100131111
→
return
01230000011122

Each corner pair is flattened into one four-integer row.

Example 2

matrix = [[0,0,1],[0,0,1],[1,1,0]]return = [[0,0,1,1],[2,2,2,2]]
matrix
012000110012110
→
return
01230001112222

This example contains two diagonally touching filled rectangles.

Example 3

matrix = [[1,1],[1,1]]return = []
matrix
01011111

This example contains no zero rectangle.

Constraints

  • For this exercise, assume row and column counts are each from 1 through 30, and all rows have the same length.
  • Every cell is the integer 0 or 1.
  • Each orthogonally connected zero component fills its bounding rectangle.

More Roblox Phone Screen questions

  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Time-Aware Search AutocompletePHONE SCREEN · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026

Similar questions at other companies

  • Matrix EscapeByteDance · PHONE SCREENByteDance interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Sudoku Board ValidationConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Reachable Exits in an Obstacle GridWhatNot · PHONE SCREENWhatNot interview questions
  • Apply a 2048 Board MoveGlean · PHONE SCREENGlean interview questions
  • Spiral Order with ObstaclesTemu · PHONE SCREENTemu interview questions
  • Find Robots by Blocker DistancesUber · PHONE SCREENUber interview questions
  • Incremental Hard Attention with a KV CacheOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • S-Shaped Matrix TraversalFox Corporation · PHONE SCREEN

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int[][] allRectangleBounds(int[][] matrix) {
        // Write your code here.
        return new int[0][];
    }
}
Checking account…