O(N) Python solution

  • 0

    Found this pretty easy myself. Same solution as I had to "Find Minimum in Rotated Sorted Array 1"

    class Solution(object):
        def findMin(self, nums):
            :type nums: List[int]
            :rtype: int
            for i in xrange(len(nums)-1):
                if nums[i] > nums[i+1]:
                    return nums[i+1]
            return nums[0]

Log in to reply

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