题目
https://leetcode-cn.com/problems/longest-increasing-subsequence/
思路
代码
class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
length = len(nums)
if length == 0:
return 0
dp = [0] * length
for i in range(length):
cur_max = 0
for j in range(i):
if nums[i] > nums[j]:
cur_max = max(cur_max, dp[j])
dp[i] = cur_max + 1
return max(dp)