Find Peak Element II
update Mar 6, 2021
The numbers in adjacent positions are different.
The matrix has n rows and m columns, n and m will not less than 3.
For all i < n, A[i][0] < A[i][1] && A[i][m - 2] > A[i][m - 1].
For all j < m, A[0][j] < A[1][j] && A[n - 2][j] > A[n - 1][j]A[i][j] > A[i + 1][j] &&
A[i][j] > A[i - 1][j] &&
A[i][j] > A[i][j + 1] &&
A[i][j] > A[i][j - 1]Input:
[[1, 2, 3, 6, 5],
[16,41,23,22, 6],
[15,17,24,21, 7],
[14,18,19,20,10],
[13,14,11,10, 9]]
Output: [1,1] Explanation: [2,2] is also acceptable.
The element at [1,1] is 41, greater than every element adjacent to it.Basic Idea
Java Code
Last updated