注意左右边界和pov
class Solution:
def minNumberInRotateArray(self, rotateArray):
# write code here
if not rotateArray:
return 0
left = 0
right = len(rotateArray)-1
while left < right:
pov = left + (right-left)//2
if rotateArray[pov] < rotateArray[right]:
right = pov
elif rotateArray[pov] > rotateArray[right]:
left = pov + 1
else:
right -= 1
return rotateArray[right]