334. 递增的三元子序列
2019-03-19 本文已影响0人
cptn3m0
LIS
有点杀鸡用牛刀的嫌疑
单调栈
时间复杂性达标, 空间需要O(n)
import sys
class Solution(object):
def increasingTriplet(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
p_f1 = sys.maxint
p_f2 = sys.maxint
for n in nums:
if n > p_f2:
return True
if n <= p_f1:
p_f1 = n
else:
p_f2 = n
return False