Bounds of One Zero Rectangle
Updated
Problem statement
Given a nonempty rectangular integer matrix matrix containing only 0 and 1, return the top-left and bottom-right corners of its one zero rectangle.
For this exercise, assume there is exactly one nonempty, filled rectangle of zeros whose sides follow the matrix’s rows and columns, and every other cell is one. 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 exactly [[top,left],[bottom,right]]; the result contains coordinates, not height and width.
Function
rectangleBounds(matrix: int[][]) → int[][]Examples
Example 1
matrix = [[1,1,1,1],[1,0,0,1],[1,0,0,1],[1,1,1,1]]return = [[1,1],[2,2]]These are the exact corner coordinates of the zero rectangle.
Example 2
matrix = [[1,1,0,0,0],[1,1,0,0,0],[1,1,1,1,1],[1,1,1,1,1]]return = [[0,2],[1,4]]This example touches the top and right borders.
Example 3
matrix = [[0,0,0]]return = [[0,0],[0,2]]This example contains one height-one rectangle.
Constraints
- For this exercise, assume row and column counts are each from
1through30, and all rows have the same length. - Every cell is the integer
0or1. - Exactly one nonempty filled zero rectangle is present.
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
- Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
- One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
- Unique Pairs in a 2D Matrix Summing to TargetAmazon · PHONE SCREEN
- Map Black Cells to Covering 2x2 BlocksSquare · PHONE SCREEN
- Trace an Eight-Direction Robot Until BlockedPinterest · PHONE SCREENPinterest interview questions
- Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
- Count Connect-Four Scoring LinesBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Target Cells in One Block per Row and ColumnWhatNot · PHONE SCREENWhatNot interview questions
- Completely Passable Grid LinesSplunk · PHONE SCREENSplunk interview questions
- Mark a Queen’s Attack BoardMotive · PHONE SCREENMotive interview questions
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)