Center of the Largest Diagonal X
Updated
Problem statement
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]The center has arm length two.
Example 2
grid = [[0,0],[0,0]]return = [-1,-1]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