300. 最长上升子序列
https://leetcode-cn.com/problems/longest-increasing-subsequence/
解法一:dp
用dp[i]
表示s[0...i]
最长的子序列长度,遍历s[0...i]
,若有0 <= j < i
使得序列s[0...j]
与s[i]
构成更长的上升子序列,则更新dp。即当nums[i] > nums[j]
时,dp[i] = max(dp[i], dp[j]+1)
最后求dp数组的最大值
最后更新于