본문 바로가기

두두의 알고리즘/문제

[이분탐색] 릿코드 Medium 74 'Search a 2D Matrix' (Python)

728x90

<문제 링크>

https://leetcode.com/problems/search-a-2d-matrix/

 

Search a 2D Matrix - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com


<문제 풀이>

1. 각 행에 target 값이 있으면 true

 

<코드>

class Solution:
    def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
        for i in matrix:
            if target in i:
                return True
            
        return False