classSolution:""" @param matrix, a list of lists of integers @param target, an integer @return a boolean, indicate whether matrix contains target """defsearchMatrix(self,matrix,target):# write your code hereifnotmatrixornotmatrix[0]:returnFalserows=len(matrix)cols=len(matrix[0])# a in [0,m*n-1]# matrix[i][j] = matrix[a/cols][a%cols]front=0end=rows*cols-1whilefront<=end:mid=(front+end)/2ifmatrix[mid/cols][mid%cols]==target:returnTrueelifmatrix[mid/cols][mid%cols]<target:front=mid+1else:end=mid-1returnFalse