100일 DSA 코딩 챌린지의 82일

발행: (2025년 12월 25일 오전 03:38 GMT+9)
1 분 소요
원문: Dev.to

Source: Dev.to

문제

2D 행렬에서 피크 요소 찾기
GeeksforGeeks problem link
난이도: 중급 정확도: 28.51%

예시

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

솔루션

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

관련 글

더 보기 »

100일 DSA 코딩 챌린지 중 Day 85

챌린지 개요: 새로운 도전에 도전하기: GeeksforGeeks POTD를 매일 풀고 내 솔루션을 공유합니다! 💻🔥 문제: 모든 주문을 처리하는 최소 시간 Geeksfor…

100일 DSA 코딩 챌린지 Day 84

문제 GeeksforGeeks – Kth smallest element in a Matrix https://www.geeksforgeeks.org/problems/kth-element-in-matrix/1 난이도: Medium | 정확도: 61.42% Gi...