Ai
1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
132-pattern.py 463 Bytes
Copy Edit Raw Blame History
Allen Liu authored 2018-10-13 13:15 +08:00 . remove unused code
# 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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search