class Solution(object):
def findNumberIn2DArray(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
i, j = len(matrix) - 1, 0
while i >= 0 and j <= len(matrix[0]) - 1:
if matrix[i][j] < target:
j += 1
elif matrix[i][j] > target:
i -= 1
else:
return True
return False
二维数组中的查找
最新推荐文章于 2021-03-12 18:54:26 发布