132 Pattern LeetCode solution in Python

1
class Solution:
2
def find132pattern(self, nums: List[int]) -> bool:
3
stack, third = [], float("-inf")
4

5
for num in reversed(nums):
6
if num < third:
7
return True
8
while stack and stack[-1] < num:
9
third = stack.pop()
10
stack.append(num)
11
return False

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0