일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- iterator
- 315. Count of Smaller Numbers After Self
- Protocol
- 시바견
- 파이썬
- Convert Sorted List to Binary Search Tree
- kaggle
- t1
- shiba
- Python
- Generator
- 프로그래머스
- attribute
- 밴픽
- Substring with Concatenation of All Words
- 30. Substring with Concatenation of All Words
- data science
- DWG
- 컴퓨터의 구조
- LeetCode
- Python Implementation
- 715. Range Module
- Python Code
- 43. Multiply Strings
- 운영체제
- Class
- Regular Expression
- concurrency
Archives
- Today
- Total
목록300. Longest Increasing Subsequence (1)
Scribbling
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 nums[j] < nums[i]: temp = max(temp, dp[j]) j -= 1 if temp != -1: dp[i] = temp + 1 else: dp[i] = 1 return max(dp) O(N**2)답게 빠르지 않다. 개선을 해보자. 2. LIS 알고리즘 (1)의 알고리즘은 하나의 숫자에 대해 계산함에 있어 이전에 나온 모든 숫자를 다 조사한다. 그러다보니 ..
Computer Science/Coding Test
2021. 11. 15. 12:50