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 33aac17 commit 47d944cCopy full SHA for 47d944c
longest-increasing-subsequence/jinah92.py
@@ -0,0 +1,12 @@
1
+# 공간 복잡도: O(n) => nums 길이만큼 dp 배열 길이만큼의 공간 사용
2
+# 시간 복잡도: O(n^2) => 외부 반복문은 O(N), 내부 반복문은 O(N) 시간이 소요되므로 총 O(N*N) = O(N^2) 소요
3
+class Solution:
4
+ def lengthOfLIS(self, nums: List[int]) -> int:
5
+ dp = [1] * len(nums)
6
+
7
+ for cur in range(1, len(nums)):
8
+ for prev in range(cur):
9
+ if nums[cur] > nums[prev]:
10
+ dp[cur] = max(dp[prev]+1, dp[cur])
11
12
+ return max(dp)
0 commit comments