Skip to content

Commit 11fba4b

Browse files
committed
feat: week6 - longest increasing subsequence
1 parent 712a408 commit 11fba4b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'''
2+
Dynamic Programming 문제로 누적합을 이용해 풀어보려 했으나 끝내 해결을 못해 참고했습니다.
3+
'''
4+
class Solution:
5+
def lengthOfLIS(self, nums: List[int]) -> int:
6+
dp = [1] * len(nums)
7+
for cur in range(1, len(nums)):
8+
for prev in range(len(nums)):
9+
if nums[prev] < nums[cur]:
10+
dp[cur] = max(1+dp[prev], dp[cur])
11+
return max(dp)

0 commit comments

Comments
 (0)