class Solution:
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
m = len(matrix)
n = len(matrix[0])
i = m-1
j = 0
while i>=0 and j < n:
if matrix[i][j]==target:
return True
elif matrix[i][j] > target:
i -= 1
elif matrix[i][j] < target:
j += 1
return False
每日一道Leetcode - 240. 搜索二维矩阵 II [从左下角开始搜]
最新推荐文章于 2024-07-21 22:27:18 发布