gitrepo_20
/
10-week-algorithm-excercise-master
/OneQuestionPerDay
/300
/longest_increasing_subsequence.py
| from typing import List | |
| class Solution: | |
| def lengthOfLIS(self, nums: List[int]) -> int: | |
| if len(nums) == 0: | |
| return 0 | |
| dp = [1] * len(nums) | |
| for i, n in enumerate(nums): | |
| for j in range(0, i): | |
| if nums[j] < nums[i]: | |
| dp[i] = max(dp[i], dp[j] + 1) | |
| return max(dp) | |