| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/pythonpeixun/LeetCode-Solutions/master/Python/132-pattern.py | [Back] [Original] |
# Time: O(n)
# Space: O(n)
class Solution(object):
def find132pattern(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
ak = float("-inf")
st = []
for i in reversed(xrange(len(nums))):
if nums[i] < ak:
return True
else:
while st and nums[i] > st[-1]:
ak = st.pop()
st.append(nums[i])
return False
| Web Proxy Viewer | New URL | Original Page |