Question: https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/

Question Name: Find Minimum in Rotated Sorted Array II

This question is essentially the same as the prevous one.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class Solution: # @param num, a list of integer # @return an integer def findMin(self, num): if num[0] < num[-1]: # Completely sorted return num[0] elif len(num) < 5: # The input is small enough to do a linear search. return min(num) else: # The length of input is greater than 2. So the division won't get # an empty list. # The input may be or may be not sorted. mid = (len(num) - 1) // 2 return min(self.findMin(num[:mid]), self.findMin(num[mid:])) |