标签:span return 解题思路 article csdn tor log lis highlight
给定一个无序的整数数组,找到其中最长上升子序列的长度
解题思路参考https://blog.csdn.net/lw_power/article/details/80758674
输入:
[10,9,2,5,3,7,101,18]
输出: 4
解释: 最长的上升子序列是 [2,3,7,101],
它的长度是 4
class Solution(object): def lengthOfLIS(self, nums): """ :type nums: List[int] :rtype: int """ a=[1]*len(nums) if len(nums)==0: return 0 for i in range(1,len(nums)): for j in range(0,i): if(nums[i]>nums[j]): a[i]=max(a[i],a[j]+1) return max(a)
标签:span return 解题思路 article csdn tor log lis highlight
原文地址:https://www.cnblogs.com/yang520ming/p/12904114.html