300.最长递增子序列
动态规划
时间复杂度:O(N^2)
空间复杂度:O(N)
func lengthOfLIS(nums []int) int {
dp := make([]int, len(nums))
ans := 0
for i := 0; i < len(nums); i++ {
dp[i] = 1
for j := 0; j < i; j++ {
if nums[j] < nums[i] && dp[i] < dp[j] + 1 {
dp[i] = dp[j] + 1
}
}
if ans < dp[i] {
ans = dp[i]
}
}
return ans
}```
300.最长递增子序列
https://blog.jerrylee.me/2021/09/c34f3fd65725.html