Regional Maximum Finder
Reported by candidates from Uber's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Uber's Regional Maximum Finder hit the December 2024 assessment circuit, and it's a classic matrix traversal problem disguised as a local optimization challenge. You're looking at a 2D grid where you need to identify cells that are greater than or equal to all their neighbors, typically in 4 or 8 directions depending on the constraint. It's not hard algorithmically, but the edge cases around boundaries and the definition of 'regional' can trip you up fast. StealthCoder's here as your safety net if you blank on the boundary logic during the live OA.
Pattern and pitfall
The pattern is depth-first-search with matrix operations. You iterate through every cell and check if it's a local maximum by comparing it to its neighbors. The trick: handle boundaries cleanly. Don't write neighbor-checking code that crashes on edges. The common mistake is either counting out-of-bounds neighbors or comparing incorrectly on the perimeter. Some versions ask you to mark regions, others just count or return coordinates. What matters is you validate neighbors exist before you access them. If you freeze during the OA, StealthCoder reads the exact constraint and gives you the neighbor-checking pattern in seconds so you don't lose 15 minutes debugging index errors.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Regional Maximum Finder cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Uber's OA.
Uber reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Regional Maximum Finder FAQ
Is this asking for local maxima or global maximum?+
Local maxima. Every cell that's greater than or equal to all its adjacent neighbors counts as a regional maximum. It's not about finding the single largest value in the grid. You'll likely return all qualifying cells or a count of them.
What counts as a neighbor, 4 directions or 8?+
The problem statement will specify. Usually it's 4 (up, down, left, right) but Uber sometimes uses 8 (including diagonals). Read the exact wording in the OA. If it's ambiguous, clarify in a comment. Both are O(rows * cols) complexity, so it doesn't change your approach.
How do I handle edges and corners without crashing?+
Check that your neighbor coordinates are in bounds before accessing the grid. A cell on the edge has fewer neighbors, and that's fine. For example, a top-left corner only has right and down neighbors. Use simple bounds checks: if row >= 0 and row < rows and col >= 0 and col < cols.
Do I need to mark visited cells or return coordinates?+
Depends on the exact wording. If it's just counting maxima, you don't need visited tracking. If it's finding connected regions of maxima, then you'll need DFS or BFS to mark each region. Check the output format in the problem statement carefully.
Can I solve this in one pass or do I need multiple iterations?+
One pass is enough. Iterate through every cell once, check if it's a local maximum, and record it. No need to revisit cells unless the problem explicitly asks for connected components, in which case you'll use DFS after the initial scan.