数据结构与算法:动态规划dp:子序列相关力扣题(上):300. 最长递增子序列、674.最长连续递增序列
300.最长递增子序列classSolution:deflengthOfLIS(self,nums:List[int])->int:length=len(nums)iflength==1:return1#dp[i]指的是以nums[i]为结尾的最长递增子序列的长度。dp=[1]*lengthmmax=1foriinrange(1,length):forjinrange(i):ifnums[i]>n