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 f18bb1c commit 55cf613Copy full SHA for 55cf613
longest-increasing-subsequence/HodaeSsi.py
@@ -0,0 +1,20 @@
1
+# 시간 복잡도 : O(nlogn)
2
+# 공간 복잡도 : O(n)
3
+# 문제 유형 : DP, Binary Search
4
+class Solution:
5
+ def lengthOfLIS(self, nums: List[int]) -> int:
6
+ dp = []
7
+ for num in nums:
8
+ if not dp or num > dp[-1]:
9
+ dp.append(num)
10
+ else:
11
+ left, right = 0, len(dp) - 1
12
+ while left < right:
13
+ mid = left + (right - left) // 2
14
+ if dp[mid] < num:
15
+ left = mid + 1
16
17
+ right = mid
18
+ dp[right] = num
19
+ return len(dp)
20
+
0 commit comments