Tap here to switch tabs
Problem
Submissions

Problem: Find a Peak Element II

med
30 min
Try to solve the Find a Peak Element II problem.

Statement

A peak element in a 22D grid is defined as an element that is strictly greater than all of its adjacent neighbors situated directly above, below, to the left, and to the right.

Given an mimesnm imes n integer matrix mat where no two adjacent cells have equal values, find any peak element and return its coordinates as [i, j], representing the row and column indices.

You may assume that the entire matrix is surrounded by an outer border of cells containing the value −1-1.

Constraints:

  • m ==== mat.length

  • n ==== mat[i].length

  • 1≤m,n≤5001 \leq m, n \leq 500

  • 1≤1 \leq mat[i][j] ≤105\leq 10^5

  • No two adjacent cells are equal.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find a Peak Element II

med
30 min
Try to solve the Find a Peak Element II problem.

Statement

A peak element in a 22D grid is defined as an element that is strictly greater than all of its adjacent neighbors situated directly above, below, to the left, and to the right.

Given an mimesnm imes n integer matrix mat where no two adjacent cells have equal values, find any peak element and return its coordinates as [i, j], representing the row and column indices.

You may assume that the entire matrix is surrounded by an outer border of cells containing the value −1-1.

Constraints:

  • m ==== mat.length

  • n ==== mat[i].length

  • 1≤m,n≤5001 \leq m, n \leq 500

  • 1≤1 \leq mat[i][j] ≤105\leq 10^5

  • No two adjacent cells are equal.