FastPrepBounds of One Zero Rectangle
Problems/Bounds of One Zero Rectangle

Bounds of One Zero Rectangle

Indeed logoIndeed● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported zero-rectangle task matches at about 95%; the corner-result choice, filled single-rectangle valid-input contract, integer indexing and finite bounds are explicitly stated.

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 rectangle filled with zeros, with its sides following the matrix 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],[1,1,0,0,1],[1,1,0,0,1],[1,1,1,1,1]]return = [[1,2],[2,3]]
matrix
01234011111111001211001311111
→
return
01012123

These are the corner coordinates of the zero rectangle in this matrix.

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]]
matrix
01234011000111000211111311111
→
return
01002114

This example touches the top and right borders.

Example 3

matrix = [[0,0,0]]return = [[0,0],[0,2]]
matrix
0120000
→
return
01000102

This example contains one height-one 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.
  • Exactly one nonempty filled zero rectangle is present.

More Indeed Phone Screen questions

  • Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Course Completion OrderPHONE SCREEN · Seen May 2025
  • Recipes You Can PreparePHONE SCREEN · Seen May 2025
  • Rotting Orange PropagationPHONE SCREEN · Seen May 2025
  • Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
  • First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
  • Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
  • Resource Transition GraphPHONE SCREEN · Seen Jul 2022
  • Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022

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

Interview reports that mention this question

  • Indeed Experienced SWE Karat Screens and OAs: 6 Experiences

Indeed interview experiences

  • Indeed SWE Intern Karat Screens and OA: 3 Experiences
  • Indeed New Grad SWE Online Assessments: 3 Experiences
All Indeed interview questionsSee Indeed hiring insights
Saved
class Solution {
    public int[][] rectangleBounds(int[][] matrix) {
        // Write your code here.
        return new int[0][];
    }
}
Checking account…