3 Line Python Solution O(n) Time and O(1) Space


  • 0
    D
    
    class Solution(object):
        def findMin(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            i = 1
            while i < len(nums) and nums[i] > nums[i-1]: i += 1
            return nums[i] if i < len(nums) else nums[0]      
    

Log in to reply
 

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