Easy one pass Python solution


  • 0
    class Solution(object):
        def increasingTriplet(self, nums):
            n = len(nums); smallest = sys.maxint; secondSmallest = sys.maxint
            for i in range(n):
                if nums[i] > secondSmallest: return True
                if nums[i] > smallest: secondSmallest = min(secondSmallest, nums[i])
                smallest = min(smallest, nums[i])
            return False
    

Log in to reply
 

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