class Solution:
def LIS(self , arr: List[int]) -> int:
# write code here
dp = [1 for _ in range(len(arr))]
res = 0
for i in range(1,len(arr)):
for j in range(i):
if arr[i]>arr[j] and dp[i]<dp[j]+1:
dp[i] = dp[j] + 1
res = max(res,dp[i])
return res
Leetcode-300 最长递增子序列
最新推荐文章于 2024-07-22 16:27:42 发布