Skip to content

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

Open

Description

@Cherrymelon

说实话我没看明白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]

Activity

  1. zhentoufei commented on Sep 30, 2017

    @zhentoufei

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

  2. Cherrymelon commented on Sep 30, 2017

    @Cherrymelon
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions