Dsa
Binary Search
Easy
Searching Peak Element in 2D Matrix
You are given a 2D integer matrix where each element is greater than its immediate neighbors (up, down, left, right). Write a function to find any peak element in the matrix and output its coordinates.
Input format:
- The first line contains two integers m and n (1 <= m, n <= 100), the number of rows and columns in the matrix.
- The next m lines each contain n integers, representing the matrix elements.
Output format:
- Two integers representing the coordinates (row, column) of one peak element found. If there is no peak, return -1 -1.
Example:
Input:
3 3
10 20 15
21 30 14
7 16 32
Output:
1 1
Key concepts
binary_searchmatrixpeak element
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now