Increasing Triplet Subsequence(二分得递增子序列)
Input:
[1,2,3,4,5]
Output:
trueInput:
[5,4,3,2,1]
Output:
falseclass Solution(object):
def increasingTriplet(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
res = []
for n in nums:
index = bisect.bisect_left(res,n)
if index ==len(res):
res.append(n)
else: res[index] = n
if index == 2:
return True
return FalseLast updated