FastPrepCenter of the Largest Diagonal X
Problems/Center of the Largest Diagonal X

Center of the Largest Diagonal X

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes a binary matrix, odd diagonal X shapes, returning a largest center, and a 3 by 5 example centered at (1,3). We supplied that size one counts, ties in row-major order, how coordinates are written, and limits. Our version is about 89% the same as the reported question.

An X of arm length k is centered on a cell containing 1 and contains 1 at every offset d from 0 through k - 1 in all four diagonal directions. Its bounding square has odd side length 2k - 1.

Return the center of an X with maximum arm length, breaking ties by row and then column. A single 1 has arm length one. Return [-1,-1] when the matrix contains no 1.

Function

largestXCenter(grid: int[][]) → int[]

Examples

Example 1

grid = [[1,0,1],[0,1,0],[1,0,1]]return = [1,1]
grid
012010110102101

The center has arm length two.

Example 2

grid = [[0,0],[0,0]]return = [-1,-1]
grid
01000100

A matrix without one returns the sentinel.

Constraints

  • 1 <= rows, columns <= 200
  • Every cell is 0 or 1.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Grid Paths with Override PassesIMC Trading · OAIMC Trading interview questions
  • Largest Square of OnesOpenAI · OAOpenAI interview questions
  • Grid Paths with Override PassesMicrosoft · OAMicrosoft interview questions
  • Minimum Moves to Spread Stones Across a GridAmerican Express · OAAmerican Express interview questions
  • Maximum Reward (Intuit India)Intuit · OAIntuit interview questions
  • Largest Plus SignxAI · OAxAI interview questions
  • Calculate the Max ValueAmazon · OA
  • Largest Square of 1'sFactSet · OAFactSet interview questions
  • Count Grid Words with One TurnCapital One · OACapital One interview questions
  • Minimum Falling Path SumScale AI · OAScale AI interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int[] largestXCenter(int[][] grid) {
        // Write your code here.
    }

}
Checking account…