Longest Continuous Increasing Subsequence
Posted 唐僧洗发爱飘柔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Longest Continuous Increasing Subsequence相关的知识,希望对你有一定的参考价值。
这道题为简单题
题目:
思路:
设置三个变量,max_long 存储总的最大长度,l代表该值目前的最大长度,num主要用来比较列表的前后大小。如果i大于num那么l就一直加1.否则l就和max_long比较大小,l变为1,num更新为i值
代码:
1 class Solution: 2 def findLengthOfLCIS(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 max_long = -float("inf") 8 num = -float("inf") 9 l = 0 10 for i in nums: 11 if i > num: l += 1 12 else: 13 if l > max_long: max_long = l 14 l = 1 15 num = i 16 return max(max_long, l)
以上是关于Longest Continuous Increasing Subsequence的主要内容,如果未能解决你的问题,请参考以下文章
674. Longest Continuous Increasing Subsequence
674. Longest Continuous Increasing Subsequence
674. Longest Continuous Increasing Subsequence
Longest Increasing Continuous Subsequence