题目描述
在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
class Solution:
# array 二维列表
def Find(self, target, array):
# write code here
#判断数组是否为空
if array == [[]]:
return False
if target < array[0][0]:
return False
elif target>array[-1][-1]:
return False
else:
for row in array:
for i in range(0,len(row)):
print(row[i])
if target == row[i]:
return True
return False
收获:return的话是直接退出函数;且要考虑数组为空的时候