class Solution():
def findmin(self,A,left,right):
if right - left == 1:
return A[right]
mid = int((left+right)/2)
if A[left] <= A[right]:
return A[left]
if A[mid] >= A[left]:
self.findmin(A,mid,right)
if A[mid] <= A[right]:
self.findmin(A,left,mid)
#test
s = Solution()
print(s.findmin([3,4,5,1,2],0,4))
网友评论