Day 82 of 100 days dsa coding challenge

Published: (December 24, 2025 at 01:38 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Problem

Find the Peak Element in a 2D Matrix
GeeksforGeeks problem link
Difficulty: Medium Accuracy: 28.51%

Example

Input: mat[][] = [[10, 20, 15],
                  [21, 30, 14]]

Solution

class Solution:
    def findPeakGrid(self, mat):
        n = len(mat)
        m = len(mat[0])
        l, r = 0, m - 1
        while l  mat[max_row][mid]:
                    max_row = i
            left = mat[max_row][mid-1] if mid-1 >= 0 else float('-inf')
            right = mat[max_row][mid+1] if mid+1 = left and mat[max_row][mid] >= right:
                return [max_row, mid]
            elif left > mat[max_row][mid]:
                r = mid - 1
            else:
                l = mid + 1
        return [-1, -1]
Back to Blog

Related posts

Read more »

Day 85 of 100 days dsa coding challenge

Challenge Overview Taking on a new challenge: solving GeeksforGeeks POTD daily and sharing my solutions! 💻🔥 Problem Minimum time to fulfil all orders Geeksfo...

Day 84 of 100 days dsa coding challenge

Problem GeeksforGeeks – Kth smallest element in a Matrixhttps://www.geeksforgeeks.org/problems/kth-element-in-matrix/1 Difficulty: Medium | Accuracy: 61.42% Gi...