原題地址:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/數組
解題思路:這道題和上一道題的區別是,數組中可能有相同的數。那麼,分下列幾種狀況:spa
代碼:code
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[L]: L = M + 1 elif num[M] < num[R]: R = M else: L += 1 return num[L]