10-line Python Solution


  • 1
    L
    class Solution(object):
        def find132pattern(self, nums):
            """
            :type nums: List[int]
            :rtype: bool
            """
            import sys
            stack = []
            s3 = -sys.maxint
            for n in nums[::-1]:
                if n < s3:
                    return True
                while stack and stack[-1] < n:
                    s3 = stack.pop()
                stack.append(n)
            return False
    

Log in to reply
 

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