Skip to content

Latest commit

 

History

History
21 lines (20 loc) · 466 Bytes

240.md

File metadata and controls

21 lines (20 loc) · 466 Bytes
  • 32ms
  • 82%
class Solution:
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        if not matrix: return False
        m = len(matrix)
        n = len(matrix[0])
        i,j = 0,n-1
        while i<m and j>=0:
            if target>matrix[i][j]: i+=1
            elif target<matrix[i][j]: j-=1
            else: return True
        return False