We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ad4b1cb commit b2912eaCopy full SHA for b2912ea
1 file changed
longest-increasing-subsequence/gcount85.py
@@ -0,0 +1,22 @@
1
+"""
2
+# Approach
3
+dp[n]은 nums[n] 위치까지 lis 길이입니다.
4
+
5
+# Complexity
6
+nums의 길이를 n이라고 할 때,
7
+- Time complexity: 이중 반복문 O(N^2)
8
+- Space complexity: dp 배열 O(N)
9
10
11
12
+class Solution:
13
+ def lengthOfLIS(self, nums: list[int]) -> int:
14
+ n = len(nums)
15
+ dp = [1] * n
16
+ answer = 1
17
+ for i in range(1, n):
18
+ for j in range(i):
19
+ if nums[j] < nums[i]:
20
+ dp[i] = max(dp[j] + 1, dp[i])
21
+ answer = max(answer, dp[i])
22
+ return answer
0 commit comments