Python simple O(n) solu


  • 0
    A
    class Solution(object):
        def increasingTriplet(self, nums):
            """
            :type nums: List[int]
            :rtype: bool
            """
            
            first = float('inf')
            second = [float('inf'), float('inf')]
            for num in nums:
                if num<=first: first = num
                elif num<=second[1]: second = [min(first,second[0]),num]
                else: return True
            return False
            
    
    

Log in to reply
 

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