classSolution:""" @param A : a list of integers @param target : an integer to be searched @return : an integer """defsearch(self,A,target):# write your code hereifnotA:return-1front=0end=len(A)-1whilefront<=end:mid=front+(end-front)/2ifA[mid]==target:returnmid# Case 1: [A[front], A[mid]] is sortedifA[front]<A[mid]:# A[mid] > target, then target could be in another subarray or [A[front], A[mid]]ifA[mid]>targetandA[front]<=target:end=mid-1# A[mid] too largeelse:front=mid+1else:# Case 2: [A[front],A[end]] is sorted# any values of left subarray are larger than right subarray # A[mid] < target, value could be in [A[mid] ...] or [A[front] ... pivot]# Go leftifA[mid]<targetandA[end]>=target:front=mid+1else:end=mid-1return-1