class Solution:
# @param num, a list of integer
# @return an integer
def findMin(self, num):
n=len(num)
strt=0
nd=n-1
while nd-strt>1:
mid=(strt+nd)//2
if num[strt]<num[nd]:
return num[strt]
elif num[strt]>num[nd]:
if num[strt]>num[mid]:
nd=mid
else:
strt=mid
else:
strt+=1
return num[strt] if num[strt]<num[nd] else num[nd]
Wednesday, October 22, 2014
Leetcode: Find Minimum in Rotated Sorted Array II @Python
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment