思想转载于:http://blog.youkuaiyun.com/hulamua/article/details/52539087
自己用python代码实现:
import sys
str1=sys.stdin.readline().strip().split()
A=[int(i) for i in str1]
d=[1]
re=[]
for i in range(len(A)):
re.append([1])
for i in range(1,len(A)):
for j in range(i):
if A[j]<A[i]:
re[i].append(d[j]+1)
d.append(max(re[i]))
print max(d)
本文介绍了一种使用Python实现的寻找最长递增子序列的算法。通过两层循环遍历数组,利用动态规划的思想记录每个元素对应的最长递增子序列长度,最终输出最大值。
1459

被折叠的 条评论
为什么被折叠?



