题解 | #Redraiment的走法#

Redraiment的走法

https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa

n = int(input())
nums = list(map(int, input().split()))
res = [1 for _ in range(n)]
#贪心 最长递增子序列
for i in range(n):
    #往前比它小的且m最大的
    cur = nums[i]
    cnt = res[i]
    for j in range(i):#前面的数
        if nums[j] < nums[i]:
            cnt = max(cnt,res[j] + 1)
    res[i] = cnt

print(max(res))

全部评论

相关推荐

白火同学:能。我当初应届沟通了1200,收简历50,面试10左右吧,加油投吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务