Find Minimum in Rotated Sorted Array

题目描述:

Find Minimum in Rotated Sorted Array_第1张图片

解法:

ps:没考虑有重复元素的情况

class Solution:
    # @param num, a list of integer
    # @return an integer
    def findMin(self, num):
        s,t=0,len(num)-1
        while num[s]>num[t]:
            mid=(s+t)/2
            if num[mid]<num[t]:
                t=mid
                continue
            else:
                s=mid+1
        return num[s]


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