일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 밴픽
- 715. Range Module
- t1
- attribute
- DWG
- LeetCode
- iterator
- Decorator
- 컴퓨터의 구조
- Python
- 프로그래머스
- Python Code
- Regular Expression
- 30. Substring with Concatenation of All Words
- 43. Multiply Strings
- 파이썬
- Protocol
- Convert Sorted List to Binary Search Tree
- Generator
- Substring with Concatenation of All Words
- data science
- Class
- 운영체제
- kaggle
- concurrency
- Python Implementation
- 315. Count of Smaller Numbers After Self
- shiba
- 109. Convert Sorted List to Binary Search Tree
- 시바견
Archives
- Today
- Total
Scribbling
LeetCode: 354. Russian Doll Envelopes 본문
매우 어려운 문제였다.
다만 아래 문제를 먼저 풀면, 이 문제도 쉽게 풀 수 있다.
https://focalpoint.tistory.com/179
from bisect import bisect_left
class Solution:
def maxEnvelopes(self, envelopes: List[List[int]]) -> int:
envelopes.sort(key=lambda x: (x[0], -x[1]))
dp = [envelopes[0][1]]
for i in range(1, len(envelopes)):
idx = bisect_left(dp, envelopes[i][1])
if idx == len(dp):
dp.append(envelopes[i][1])
else:
dp[idx] = envelopes[i][1]
return len(dp)
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 295. Find Median from Data Stream (0) | 2021.11.16 |
---|---|
LeetCode: 347. Top K Frequent Elements (0) | 2021.11.15 |
LeetCode: 300. Longest Increasing Subsequence (0) | 2021.11.15 |
LeetCode: 132. Palindrome Partitioning II (0) | 2021.11.13 |
LeetCode: 131. Palindrome Partitioning (0) | 2021.11.13 |