Find Minimum in Rotated Sorted Array II

Medium, Binary Search

Question

接Find Minimum in Rotated Sorted Array,
假设有重复数字。

Solution

解法依然是二分搜索,不过多了一种情况要考虑。

class Solution(object):
    def findMin(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        L, R = 0, len(nums)-1
        while L=nums[R]:
            M = (L+R)/2
            if nums[M]>nums[R]:
                L = M+1
            elif nums[M]

你可能感兴趣的:(Find Minimum in Rotated Sorted Array II)