How about doing comparison just between two adjoining numbers?

  • 0

    we can treat the array as n-1 pairs ,
    each of them has two adjoining numbers,
    So what we should do is just finding the reverse pair

    here is my code in Python:

    def findMin(self, num):
        if len(num) == 1:
            return num[0]
        elif num[0] <= num[len(num)-1]:
            return num[0]
            for i in range(len(num)-1):
                if num[i] >= num[i+1]:
                    return num[i+1]

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.