674. Longest Continuous Increasing Subsequence

Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increasing.

continuous increasing subsequence is defined by two indices l and r (l < r) such that it is [nums[l], nums[l + 1], ..., nums[r - 1], nums[r]] and for each l <= i < rnums[i] < nums[i + 1].



def findLengthOfLCIS(nums: List[int]):
   
    ans = start = 0
   
    for i in range(len(nums)):
        if i and nums[i] <= nums[i-1]:
            start = i
        ans = max(ans, i - start + 1)
       
    return ans

     

Comments

Popular posts from this blog

849. Maximize Distance to Closest Person

347. Top K Frequent Elements

139. Word Break