Longest Continuous Increasing Subsequence - Problem
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.
A 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 < r, nums[i] < nums[i + 1].
Input & Output
Example 1 — Basic Increasing Sequence
$
Input:
nums = [1,3,6,7]
›
Output:
4
💡 Note:
The entire array is continuously increasing: 1 < 3 < 6 < 7, so the length is 4
Example 2 — Mixed Sequence
$
Input:
nums = [2,2,2,2,2]
›
Output:
1
💡 Note:
All elements are equal, no strictly increasing subsequence longer than 1 exists
Example 3 — Multiple Increasing Parts
$
Input:
nums = [1,3,6,2,8]
›
Output:
3
💡 Note:
Longest increasing subsequence is [1,3,6] with length 3. The sequence [2,8] has length 2.
Constraints
- 1 ≤ nums.length ≤ 104
- -109 ≤ nums[i] ≤ 109
Visualization
Tap to expand
Understanding the Visualization
1
Input Array
Array with mixed increasing and decreasing parts
2
Find Sequences
Identify all continuous increasing parts
3
Return Length
Length of the longest increasing part
Key Takeaway
🎯 Key Insight: Track current length while scanning, reset when sequence breaks, keep maximum
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code