classSolution: defsearchMatrix(self, matrix: List[List[int]], target: int) -> bool: m, n = len(matrix), len(matrix[0]) if target < matrix[0][0]: returnFalse if target > matrix[m-1][n-1]: returnFalse i, j = 0, n-1 while i < m and j >= 0: right_top = matrix[i][j] if target == right_top: returnTrue if target < right_top: j -= 1 else: i += 1 returnFalse