일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- LeetCode
- data science
- 컴퓨터의 구조
- Decorator
- Generator
- iterator
- t1
- 109. Convert Sorted List to Binary Search Tree
- Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- 시바견
- Substring with Concatenation of All Words
- kaggle
- 43. Multiply Strings
- Python
- Protocol
- 315. Count of Smaller Numbers After Self
- concurrency
- Python Implementation
- 715. Range Module
- Regular Expression
- Class
- 밴픽
- shiba
- DWG
- 프로그래머스
- 파이썬
- attribute
- Python Code
- 운영체제
Archives
- Today
- Total
Scribbling
LeetCode: 334. Increasing Triplet Subsequence 본문
Computer Science/Coding Test
LeetCode: 334. Increasing Triplet Subsequence
focalpoint 2022. 1. 11. 20:38This problem is a special case of #300, which is LIS.
Refer to LIS algorithm here.
https://focalpoint.tistory.com/179
class Solution:
def increasingTriplet(self, nums: List[int]) -> bool:
dp = [nums[0]]
for i in range(1, len(nums)):
num = nums[i]
insert_flag = False
for j in range(len(dp)):
if num <= dp[j]:
dp[j] = num
insert_flag = True
break
if not insert_flag:
dp.append(num)
if len(dp) == 3:
return True
return False
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 378. Kth Smallest Element in a Sorted Matrix (0) | 2022.01.14 |
---|---|
LeetCode: 341. Flatten Nested List Iterator (0) | 2022.01.13 |
LeetCode: 329. Longest Increasing Path in a Matrix (0) | 2022.01.11 |
LeetCode: 350. Intersection of Two Arrays II (0) | 2022.01.10 |
LeetCode: 322. Coin Change (0) | 2022.01.07 |