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
Longest Continuous Increasing SubsequenceInput: [1, 3, 6, 2, 8]13628Increasing: 1→3→6Length: 3Increasing: 2→8Length: 2The longest continuous increasing subsequence has length 3Output: 3
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
Asked in
Facebook 35 Apple 28
32.4K Views
Medium Frequency
~15 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen