首页 > 其他 > 详细

674. Longest Continuous Increasing Subsequence

时间:2020-07-14 01:03:41      阅读:76      评论:0      收藏:0      [点我收藏+]

Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).

找最长连续上升子序列

class Solution(object):
    def findLengthOfLCIS(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        n = len(nums)
        global_max = 1 if n > 0 else 0
        current_max = 1
        for i in range(1, len(nums), 1):
            if nums[i] > nums[i - 1]:
                current_max += 1
                global_max = max(global_max, current_max)
            else:
                current_max = 1
        return global_max
            
            

 

674. Longest Continuous Increasing Subsequence

原文:https://www.cnblogs.com/whatyouthink/p/13296616.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!