解法一:时间复杂度O(m+n) 空间复杂度O(1)
class Solution:
def findNumberIn2DArray(self, matrix: List[List[int]], target: int) -> bool:
i,j = len(matrix) - 1,0
while i >= 0 and j < len(matrix[0]):
if matrix[i][j] > target:i -= 1
elif matrix[i][j] < target: j += 1
else:return True
return False
解法二:二分查找
解法三:递归