Skip to content

Commit e60be98

Browse files
author
sangbeenmoon
committed
tried LIS.
1 parent 6e4f683 commit e60be98

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# hint 를 보고 해결.
2+
# DP 로도 풀 수 있음.
3+
4+
class Solution:
5+
def lengthOfLIS(self, nums: List[int]) -> int:
6+
seq = []
7+
8+
9+
for num in nums:
10+
if len(seq) == 0:
11+
seq.append(num)
12+
continue
13+
14+
i = 0
15+
16+
while seq[i] < num:
17+
i = i + 1
18+
19+
if i > len(seq) - 1:
20+
break
21+
22+
if i > len(seq) - 1:
23+
seq.append(num)
24+
else:
25+
seq[i] = num
26+
27+
return len(seq)

0 commit comments

Comments
 (0)