Solution:
# T:O(lgn)~O(n) S:O(1) class Solution: # @param num, a list of integer # @return an integer def findMin(self, num): low, high = 0, len(num) while low < high - 1 and num[low] >= num[high - 1]: mid = low + (high - low) / 2 if num[mid] > num[low]: low = mid + 1 elif num[mid] < num[low]: if mid == high - 1: return num[mid] else: high = mid + 1 else: low += 1 return num[low]Run Time: 48 ms
No comments:
Post a Comment