当前位置:网站首页>Force buckle 674 Longest continuous increasing sequence

Force buckle 674 Longest continuous increasing sequence

2022-07-07 20:06:00 Tomorrowave

674. The longest continuous increasing sequence

Given an unordered array of integers , Find the longest and Successive increasing subsequences , And return the length of the sequence .

Successive increasing subsequences It can be made up of two subscripts l and r(l < r) determine , If for each l <= i < r, There are nums[i] < nums[i + 1] , So the subsequence [nums[l], nums[l + 1], …, nums[r - 1], nums[r]] It's a continuous increasing subsequence .

### Knowledge points involved
Dynamic programming

class Solution:
    def findLengthOfLCIS(self, nums: List[int]) -> int:
        ans=[1 for _ in range(len(nums))]
        for i in range(1,len(nums)):
            if nums[i]>nums[i-1]:
                ans[i]=ans[i-1]+1
        return max(ans)
原网站

版权声明
本文为[Tomorrowave]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071753356784.html