天天看点

leetcode 674. Longest Continuous Increasing Subsequence python

给定无序整数数组,计算最长连续递增子序列的长度

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