Count Strict Grid Maxima
Updated
Problem statement
Count cells whose value is strictly greater than every existing orthogonal neighbor (up, down, left, right). Diagonal cells are not neighbors. At the boundary compare only neighbors inside the grid. A one-cell grid therefore has one maximum.
Function
countMaxima(grid: int[][]) → intExamples
Example 1
grid = [[1,4,1],[3,2,5]]return = 3The cells with values 4,3,5 exceed each of their orthogonal neighbors.
Example 2
grid = [[7]]return = 1There are no existing neighbors to disqualify the only cell.
Constraints
- For this exercise, assume a nonempty rectangular grid with at most 200000 cells; each value is a signed 32-bit integer.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Survey Table: Group Given an AnswerSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
- Query a Header-Encoded MatrixNVIDIA · OANVIDIA interview questions
- Trapped Characters in a GridAdobe · OAAdobe interview questions
- Center Crop a Grayscale ImageLuma AI · OALuma AI interview questions
- Find Zero Cells in a 2×2 GridRoblox · OARoblox interview questions
- Make Pixel Columns Strictly IncreasingMicrosoft · OAMicrosoft interview questions
- Count Pieces After Othello MovesHudson River Trading · OAHudson River Trading interview questions
- Tic-Tac-Toe Board StatusPinecone · OA
- Cherry PickupInfosys · OAInfosys interview questions