https://leetcode.com/problems/increasing-triplet-subsequence/
find increasing triplet sequence
a < b < c
a_i < b_i < c_i
idea: moving minimum!!!!!!
class Solution:
def increasingTriplet(self, nums: List[int]) -> bool:
left = 0
mid = -1
for i, n in enumerate(nums):
l = nums[left]
m = nums[mid]
if l > n:
left = i
elif mid > -1 and m < n:
return True
elif l < n:
mid = i
return False
'algorithm' 카테고리의 다른 글
1155. Number of Dice Rolls With Target Sum (0) | 2020.09.07 |
---|---|
300. Longest Increasing Subsequence (0) | 2020.09.06 |
473. Matchsticks to Square (0) | 2020.09.03 |
676. Implement Magic Dictionary (0) | 2020.09.03 |
662. Maximum Width of Binary Tree (0) | 2020.08.31 |