LC 0334 [M] Increasing Triplet Subsequence - ALawliet/algorithms GitHub Wiki
class Solution:
def increasingTriplet(self, nums: List[int]) -> bool:
# we can use two thresholds to divide the subsquence length
# everything between a and b will form doublets
# everything above b will form a triplet
# dynamically change these two thresholds
a = b = float("inf")
for x in nums:
# lower a
if x <= a:
a = x
# lower b
elif x <= b:
b = x
# if greater than both thresholds (note equal doesn't count)
else:
# c = num
return True
return False