#674

Longest Continuous Increasing Subsequence

pupil · 435 · lc easy +25 · verified · 51.9% accepted · 2,464 likes · top 41%

Description

Given an unsorted integer array nums, find the length of its longest contiguous strictly increasing subarray. A contiguous increasing subarray spans indices l through r (l < r) such that nums[i] < nums[i + 1] holds for every l <= i < r.

Example 1:

Input: nums = [1,3,5,4,7]
Output: 3
Explanation: The longest continuous increasing subsequence is [1,3,5] with length 3.
Even though [1,3,5,7] is an increasing subsequence, it is not continuous as elements 5 and 7 are separated by element
4.

Example 2:

Input: nums = [2,2,2,2,2]
Output: 1
Explanation: The longest continuous increasing subsequence is [2] with length 1. Note that it must be strictly
increasing.

Code

1
2
3