# -*- coding:utf-8 -*-
class Solution:
# array 二维列表
def Find(self, target, array):
# write code here
row=len(array)
if row==0:
return False
col=len(array[0])
if col==0:
return False
indexrow=row-1
indexcol=0
while indexrow>=0 and indexcol<col:
s=array[indexrow][indexcol]
if s==target:
return True
elif s<target:
indexcol+=1
elif s>target:
indexrow-=1
return False
要保证数组能在一个方向是递增,一个方向是递减,所以要从左下角开始遍历