Skip to content

Commit a812314

Browse files
committed
solve : longest increasing subsequence
1 parent 74e04c9 commit a812314

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# TC : O(n^2)
2+
# SC : O(n)
3+
class Solution:
4+
def lengthOfLIS(self, nums: List[int]) -> int:
5+
dp = [1] * len(nums)
6+
for cur in range(1, len(nums)):
7+
for pre in range(cur):
8+
if nums[pre] < nums[cur]:
9+
dp[cur] = max(1 + dp[pre], dp[cur])
10+
return max(dp)

0 commit comments

Comments
 (0)