Pythonic solution

  • 0
    def increasingTriplet(self, nums):
        if len(nums) < 3: return False      # corner case
        nmin = nmid = float("Inf")
        for i in nums:
            if i > nmid: return True        # found the third piglet. hooray.
            if nmin < i < nmid: nmid = i    # found the middle piglety
            if i < nmin: nmin = i           # found the first piglet
        return False

Log in to reply

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