Nonzero Local Maxima in Cornerless Neighborhoods
Updated
Problem statement
For each nonzero cell, consider its in-bounds orthogonal neighbors—the centered 3 by 3 neighborhood with all four corners excluded. The cell is a local maximum when its value is strictly greater than every such neighbor.
Return zero-based [row,column] coordinates of all local maxima in row-major order. A nonzero cell with no orthogonal neighbor qualifies.
Function
cornerlessLocalMaxima(matrix: int[][]) → int[][]Examples
Example 1
matrix = [[1,2,1],[2,9,2],[1,2,1]]return = [[1,1]]The center exceeds all four orthogonal neighbors.
Example 2
matrix = [[5,5]]return = []Strict comparison rejects both equal cells.
Constraints
1 <= rows, columns <= 1000-1000000000 <= matrix[r][c] <= 1000000000
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
- Survey Table: Group Given an AnswerSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Maximum Remaining Drone PowerAkuna Capital · OAAkuna Capital interview questions
- Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
- Query a Header-Encoded MatrixNVIDIA · OANVIDIA interview questions
- Squared Frobenius Norm of a Reflect-and-Stretch MapWalleye Capital · OA
- Invert or Blur an ImageOpenAI · OAOpenAI interview questions
- Trapped Characters in a GridAdobe · OAAdobe interview questions
- Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions
- Connected GroupsVisa · OAVisa interview questions
- Center Crop a Grayscale ImageLuma AI · OALuma AI interview questions