题解 | #旋转数组的最小数字#
旋转数组的最小数字
http://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba
class Solution: def minNumberInRotateArray(self, rotateArray): l,r=0,len(rotateArray)-1 while l<r: while 1: if r-1>l and rotateArray[r]==rotateArray[r-1]: r-=1 else: break while 1: if l+1<r and rotateArray[l]==rotateArray[l+1]: l+=1 else: break mid = (l+r)//2 if rotateArray[mid]>rotateArray[r]: l=mid+1 else: if rotateArray[mid]<rotateArray[l]: r=mid else: return rotateArray[l] return rotateArray[l]