Find a Peak Element II
A medium-tier problem at 53% community acceptance, tagged with Array, Binary Search, Matrix. Reported in interviews at Zeta and 0 others.
Find a Peak Element II is a medium-difficulty matrix problem that hits a blind spot for most candidates: it looks like it needs brute force iteration, but the optimal solution uses binary search on rows and columns in a way that feels unintuitive at first. You're given a 2D matrix and need to find any cell where the value is strictly greater than its adjacent neighbors (up, down, left, right). The 50% acceptance rate signals that half the people who attempt it either timeout with nested loops or miss the binary search pattern entirely. If this problem shows up in your live OA and you blank on the approach, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Find a Peak Element II"
Find a Peak Element II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe trap is thinking you need to compare every element to every neighbor, which drags you into O(m*n) territory. The real insight: apply binary search on the middle column (or row), find the maximum in that column, then use the property that a peak must exist by recursively searching the half where the element is larger than the middle. This reduces complexity to O(m*log(n)) or O(n*log(m)) depending on your axis choice. Most candidates either attempt a 2D exhaustive search or confuse this with 1D peak-finding and try linear logic. The matrix structure and the 'adjacent' constraint are the puzzle pieces: they let you eliminate half the search space each iteration without missing a peak. When you hit this on assessment day and the nested-loop instinct kicks in, StealthCoder runs silently and delivers the binary search template with the column-split logic already baked in.
Pattern tags
You know the problem.
Make sure you actually pass it.
Find a Peak Element II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find a Peak Element II interview FAQ
Is this really asked in interviews or just theoretical?+
Yes. Zeta reports this problem in their hiring cycle. The 50% acceptance rate means it's hard enough to differentiate candidates but common enough that prep matters. It's not a rare edge case.
Can I just iterate through the matrix and check each element?+
You can, but it's O(m*n) time and will timeout on large inputs. The binary search approach is O(m*log(n)), which is the expected solution. Interviewers will push back on brute force.
How does binary search work on a 2D matrix?+
Pick the middle column, find its max element, then compare it to its left and right neighbors. Recursively search the column where the neighbor is larger. This works because a peak must exist in the half you choose, so you cut the search space in half each step.
What's the difference between this and the 1D peak-finding problem?+
1D peak-finding has left/right neighbors. Here you have four directions. The matrix structure lets you use column-based binary search instead of element-by-element comparison, which is the whole trick.
Will I get away with a greedy approach?+
No. Greedy (picking the max in a column and moving toward a larger neighbor) can trap you in local maxima. Binary search guarantees you find a peak because the search space always contains one.
Want the actual problem statement? View "Find a Peak Element II" on LeetCode →