重点:
数组为空
排好序
上面行的右边的数也可以比下面行左边的数大
顺序查找
def Find(self, target, array): # write code here if len(array)==0 or len(array[0])==0: return 0 l=0 r=len(array[0])-1 for i in range(len(array)): if array[i][0]<=target<=array[i][-1]: for j in range(len(array[i])): if array[i][j]==target: return True return False
二分查找
def Find(self, target, array): # write code here if len(array)==0 or len(array[0])==0: return 0 for i in range(len(array)): if array[i][0]<=target<=array[i][-1]: l=0 r=len(array[0])-1 while(l<=r): mid=l+(r-l)//2 if array[i][mid]<target : l=mid+1 elif array[i][mid]>target: r=mid-1 else: return True return False