Skip to content

Commit a8cc3c8

Browse files
author
sejineer
committed
longest-increasing-subsequence solution
1 parent 01bd5c4 commit a8cc3c8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
시간 복잡도: O(Nlog(N))
3+
공간 복잡도: O(N)
4+
"""
5+
from bisect import bisect_left
6+
7+
class Solution:
8+
def lengthOfLIS(self, nums: List[int]) -> int:
9+
sub = []
10+
for num in nums:
11+
index = bisect_left(sub, num)
12+
if index == len(sub):
13+
sub.append(num)
14+
else:
15+
sub[index] = num
16+
return len(sub)

0 commit comments

Comments
 (0)