classSolution: defsearch(self, nums: List[int], target: int) -> bool: n = len(nums) deffind_start()->int: # 找最小。 i = 0 while i<n-1and nums[i]<=nums[i+1]: i += 1 return i+1if i+1!=n else0 defsearch_II(nums,target)-> bool: left,right = 0,len(nums)-1 while left<=right: mid = (left+right)>>1 if nums[mid]==target: returnTrue elif nums[mid]<target: left = mid+1 else: right = mid-1 returnFalse min_idx = find_start() print("min is: ",min_idx) ans = search_II(nums[min_idx:],target) if ans == True: returnTrue ans = search_II(nums[0:min_idx],target) return ans