Python 5 lines O(n) solution


  • 0
    K
    class Solution(object):
        def findMin(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            prev = nums[0]
            for i in range(1, len(nums)):
                if nums[i] < prev:
                    return nums[i]
            return prev
    

Log in to reply
 

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