【剑指offer】二维数组中的查找【python】

class Solution:
    # array 二维列表
    def Find(self, target, array):
        # write code here
        cols = len(array[0])
        rows = len(array)
        print(rows, cols)
        row, col = 0, cols - 1
        while row != rows and col != -1:
            print(row, col)
            if array[row][col] == target:
                return True
            elif array[row][col] > target:
                col -= 1
            else:
                row += 1
        return False
target = 7
array = [[1,2,8,9],[4,7,10,13]]
print(Solution().Find(target, array))

相关文章:

  • 2021-05-15
  • 2021-11-29
  • 2021-11-07
  • 2022-02-10
  • 2021-09-18
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2022-01-11
  • 2021-06-06
  • 2021-06-17
  • 2021-12-09
  • 2021-11-28
相关资源
相似解决方案