原題地址:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/數組
解題思路:話說leetcode上面的二分查找題目真的很多啊。下圖是這道題的數組的兩種狀況,分別去處理就能夠了。spa
class Solution: # @param num, a list of integer # @return an integer def findMin(self, num): L = 0; R = len(num)-1 while L < R and num[L] > num[R]: M = (L+R)/2 if num[M] < num[R]: R = M else: L = M+1 return num[L]