FastPrepNonzero Local Maxima in Cornerless Neighborhoods
Problems/Nonzero Local Maxima in Cornerless Neighborhoods

Nonzero Local Maxima in Cornerless Neighborhoods

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes nonzero candidates, strict local-maximum comparison, a centered neighborhood without corners, and returned [row,column] coordinates. The wording about a variable radius is inconsistent, so we use the orthogonal 3 by 3 neighborhood that the examples show. Our version is about 76% the same as the reported question.

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]]
matrix
012012112922121
→
return
01011

The center exceeds all four orthogonal neighbors.

Example 2

matrix = [[5,5]]return = []
matrix
01055

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

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[][] cornerlessLocalMaxima(int[][] matrix) {
        // Write your code here.
    }

}
Checking account…