1. 程式人生 > >劍指offer python版 二維數組的查找

劍指offer python版 二維數組的查找

param row nbsp 查找 二維數組的查找 elif == urn clas

def find_integer(matrix, num):
    """
    :param matrix: [[]]
    :param num: int
    :return: bool
    """
    if not matrix:
        return False
    rows, cols = len(matrix), len(matrix[0])
    row, col = rows - 1, 0
    while row >= 0 and col <= cols - 1:
        if matrix[row][col] == num:
            
return True elif matrix[row][col] > num: row -= 1 else: col += 1 return False

劍指offer python版 二維數組的查找