VISUALGO//PROBLEMS
increasing triplet subsequence · array / stringmedium
nums
1
2
3
4
5
ELEMENTS
nums
Python
def increasingTriplet(nums: list[int]) -> bool:
first = float('inf')
second = float('inf')
for num in nums:
if num <= first:
first = num
elif num <= second:
second = num
else:
# Found a third value greater than both
return True
return False