其他分享
首页 > 其他分享> > LC.334. Increasing Triplet Subsequence

LC.334. Increasing Triplet Subsequence

作者:互联网

在这里插入图片描述

class Solution(object):
    def increasingTriplet(self, nums):
        """
       每次记录最小的两个值,如果新的num比这两个最小值都要大,那么满足
        """
        small1, small2 = float("inf"), float("inf")
        for num in nums:
            if num <= small1:
                small1 =  num
            elif num <= small2:
                small2 = num
            else:
                return True
        return False

标签:small1,Triplet,nums,float,Subsequence,num,small2,inf,Increasing
来源: https://blog.csdn.net/dpengwang/article/details/90735988