码迷,mamicode.com
首页 > 其他好文 > 详细

674. Longest Continuous Increasing Subsequence

时间:2020-07-14 00:26:48      阅读:59      评论:0      收藏:0      [点我收藏+]

标签:lcis   incr   return   longest   col   int   lob   elf   ret   

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

标签:lcis   incr   return   longest   col   int   lob   elf   ret   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!