Find Minimum in Rotated Sorted Array II
class Solution(object):
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
start, end = 0, len(nums)-1
while start + 1 < end:
mid = (start+end)/2
#if mid equals to end, that means it's fine to remove end,the smallest element won't be removed
if nums[mid] == nums[end]:
end -= 1
elif nums[mid]>nums[end]:
#minV = min(minV, nums[start])
start = mid
else:
#minV = min(minV, nums[mid])
end = mid
return min(nums[start], nums[end])Last updated