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
上一篇:[论文笔记]CVPR2016_Person re-identifcation by multi-channel parts-based cnn with improved triplet loss f


下一篇:设计抽象数据类型三元组并完成一系列操作