题目描述: 33题
方法一:
class Solution: def search(self, nums: List[int], target: int) -> bool: l, r = 0, len(nums) - 1 while l <= r: m = (l+r) // 2 if target == nums[m]: return True if nums[m]==nums[l]==nums[r]: l += 1 r -= 1 elif nums[m] >= nums[l]: if nums[l] <= target < nums[m]: r = m - 1 else: l = m + 1 else: if nums[m] < target <= nums[r]: l = m + 1 else: r = m - 1 return False
原文:https://www.cnblogs.com/oldby/p/11180038.html