674 Longest Continuous Increasing Subsequence

https://leetcode.com/problems/longest-continuous-increasing-subsequence/

solution

  • 贪心

class Solution:
    def findLengthOfLCIS(self, nums: List[int]) -> int:
        res = 1
        this_res = 1
        for i in range(1, len(nums)):
            if nums[i] > nums[i-1]:
                this_res += 1
                res = max(this_res, res)
            else:
                this_res = 1
        return res

时间复杂度:O() 空间复杂度:O()

时间复杂度:O() 空间复杂度:O()

Last updated