Skip to content

Commit 6d5ba91

Browse files
author
jinbeom
committed
Longest Increasing Subsequence Solution
1 parent 36259bf commit 6d5ba91

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+
# 시간복잡도: O(N)
2+
# 공간복잡도: O(N)
3+
from bisect import bisect_left
4+
5+
class Solution:
6+
def lengthOfLIS(self, nums: List[int]) -> int:
7+
path = []
8+
9+
for num in nums:
10+
idx = bisect_left(path, num)
11+
if len(path) > idx:
12+
path[idx] = num
13+
else:
14+
path.append(num)
15+
16+
return len(path)

0 commit comments

Comments
 (0)