版权声明:本文由lianyhai编写,不得用于商业用途,其他用途请随便。如果非要用做商业用途请给我微信打一下钱谢谢!哈哈哈哈 https://blog.csdn.net/qq_36303521/article/details/88223339
用python的第一直觉就是
# -*- coding:utf-8 -*-
class Solution:
def minNumberInRotateArray(self, rotateArray):
# write code here
if len(rotateArray) ==0 :
return 0
else: return min(rotateArray)
运行时间:688ms
占用内存:6032k
然后我觉得会不会简单了点
然后就用优化一点点的排序做
# -*- coding:utf-8 -*-
class Solution:
def minNumberInRotateArray(self, rotateArray):
# write code here
long=len(rotateArray)
if long ==0 :
return 0
for i in range(long-1):
if rotateArray[i] > rotateArray[i+1]:
return rotateArray[i+1]
运行时间:673ms
占用内存:5856k