Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

旋转数组的最小值,下面算法和lz的一样? #2

Open
Cherrymelon opened this issue Sep 14, 2017 · 2 comments
Open

旋转数组的最小值,下面算法和lz的一样? #2

Cherrymelon opened this issue Sep 14, 2017 · 2 comments

Comments

@Cherrymelon
Copy link

说实话我没看明白lz写的,但是测试了下我的,居然一样

class Solution:
    def minNumberInRotateArray(self, rotateArray):
        if len(rotateArray)==0:
            return 0
        head =0
        rear = len(rotateArray)-1
        while rotateArray[head]<=rotateArray[head+1]:
            head+=1
        return rotateArray[head+1]
@zhentoufei
Copy link

哇,你的复杂度是O(n),使用二分查找的方法复杂度是O(logn)哦~你的方法也是很不错的,容易理解

@Cherrymelon
Copy link
Author

对,后来我也反应过来复杂度不一样

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants