题目
https://leetcode.cn/problems/longest-increasing-subsequence/?envType=study-plan-v2&envId=dynamic-programming
题解
1 2 3 4 5 6 7 8 9 10 11 12
| class Solution: def lengthOfLIS(self, nums: List[int]) -> int: lst = [1]*len(nums) i = 1 while i<len(nums): for j in range(i): if nums[j]<nums[i]: if lst[j]+1 > lst[i]: lst[i] = lst[j]+1 i += 1 return max(lst)
|