일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- LeetCode
- kaggle
- Regular Expression
- 프로그래머스
- shiba
- DWG
- concurrency
- 315. Count of Smaller Numbers After Self
- Class
- 시바견
- data science
- 밴픽
- 109. Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- 715. Range Module
- Protocol
- t1
- 운영체제
- Python Implementation
- Generator
- Decorator
- 30. Substring with Concatenation of All Words
- 파이썬
- attribute
- Python
- iterator
- Python Code
- Substring with Concatenation of All Words
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
Archives
- Today
- Total
Scribbling
LeetCode: 354. Russian Doll Envelopes 본문
매우 어려운 문제였다.
다만 아래 문제를 먼저 풀면, 이 문제도 쉽게 풀 수 있다.
https://focalpoint.tistory.com/179
LeetCode: 300. Longest Increasing Subsequence - 시바견의 끄적임
1. 가장 간단한 DP 형태 O(N**2)이다. class Solution: def lengthOfLIS(self, nums: List[int]) -> int: dp = [0] * len(nums) dp[0] = 1 for i in range(1, len(nums)): temp = -1 j = i - 1 while j >= 0: if n..
focalpoint.tistory.com
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 |