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 78 of 100 days dsa coding challenge

Taking on a new challenge: solving GeeksforGeeks POTD daily and sharing my solutions! 💻🔥 The goal: sharpen problem‑solving skills, level up coding, and learn...

Day 76 of 100 days dsa coding challenge

Problem Bus Conductor – GeeksforGeekshttps://www.geeksforgeeks.org/problems/bus-conductor--170647/1 Difficulty: Easy Accuracy: 75.3% Examples Example 1 - Input...

Palindrome Checker

What is a palindrome? A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward ignoring spaces, punctua...