class Solution:
def increasingTriplet(self, nums: List[int]) -> bool:
n1 = n2 = float('inf')
for n in nums:
if n < n1:
n1 = n
elif n1 < n < n2:
n2 = n
elif n1 < n2 < n:
return True
return False
'CS > 알고리즘' 카테고리의 다른 글
[Leetcode] 1822. Sign of the Product of an Array (0) | 2023.05.02 |
---|---|
[Leetcode] 121. Best Time to Buy and Sell Stock (0) | 2023.05.02 |
[Leetcode] 162. Find Peak Element (0) | 2023.05.02 |
[Leetcode] 153. Find Minimum in Rotated Sorted Array (0) | 2023.05.02 |
[Leetcode] 74. Search a 2D Matrix (0) | 2023.05.01 |