Find a Peak Element II

Medium · Binary Search · about 25 minutes

Asked at Meta, Google, Amazon, Uber, Bloomberg.

In the grid mat, call a cell a *peak* when its value beats each of its up-to-4 side neighbors (treat anything beyond the grid's edge as −1). Neighboring cells never hold equal values, and each test grid contains exactly one peak. Return the peak's coordinates [r, c], aiming for O(m log n) or O(n log m) time.

Related guides