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

Question Name: Find Minimum in Rotated Sorted Array

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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) < 3: # 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. mid = (len(num) - 1) // 2 return min(self.findMin(num[:mid]), self.findMin(num[mid:])) |