일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Class
- Protocol
- Convert Sorted List to Binary Search Tree
- data science
- attribute
- 밴픽
- 프로그래머스
- concurrency
- Decorator
- 30. Substring with Concatenation of All Words
- 파이썬
- Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- 시바견
- 운영체제
- 715. Range Module
- Regular Expression
- shiba
- Python
- LeetCode
- kaggle
- 컴퓨터의 구조
- Generator
- t1
- DWG
- 43. Multiply Strings
- iterator
- 109. Convert Sorted List to Binary Search Tree
- Python Code
- Python Implementation
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 |