classSolution:defsearch(self,nums: List[int],target:int) ->bool: left =0 right =len(nums)-1while left <= right:while left < right and nums[left]== nums[left +1]: left +=1while left < right and nums[right]== nums[right -1]: right -=1 mid = left + (right - left) //2if nums[mid]== target:returnTrueelif nums[mid]>= nums[left]:if nums[left]<= target < nums[mid]: right = mid -1else:# nums[left] > target or nums[mid] <= target: left = mid +1else:if nums[mid]< target <= nums[right]: left = mid +1else:# target <= nums[mid] or target > nums[right]: right = mid -1returnFalse