human
I am working on the file "02_BinarySearch.ipynb".
The first task is:
Follow up for "Search in Rotated Sorted Array":

What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Can you write Python code for it?
 Here if duplicates are allowed?
assistant
#Here if duplicates are allowed.

class Solution(object):
    def search(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: bool
        """
        if nums is None or len(nums) == 0:
            return False
        
        start, end = 0, len(nums)-1
        while start + 1 < end:
            mid = start + (end - start) / 2
            if nums[mid] == target:
                return True
            if nums[mid] == nums[end]:
                end -= 1
            elif nums[mid] > nums[end]:
                if nums[end] < target < nums[mid]:
                    end = mid - 1
                else:
                    start = mid
            else:
                if nums[mid] < target <= nums[end]:
                    start = mid + 1
                else:
                    end = mid
        
        return True if nums[start] == target or nums[end] == target else False