1901. Find a Peak Element II
Problem Statement
A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.
Given a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].
You may assume that the entire matrix is surrounded by an outer perimeter with the value -1 in each cell.
You must write an algorithm that runs in O(m log(n)) or O(n log(m)) time.
Example 1:

Example 2:

Constraints:
m == mat.lengthn == mat[i].length1 <= m, n <= 5001 <= mat[i][j] <= 105No two adjacent cells are equal.
Intuition
Links
https://leetcode.com/problems/find-a-peak-element-ii/description/
Video Links
https://www.youtube.com/watch?v=nGGp5XBzC4g&ab_channel=takeUforward
Approach 1:
Approach 2:
Approach 3:
Approach 4:
Similar Problems
Last updated