EasyNeetCode150Array

Longest Continuous Increasing Subsequence

Find longest continuous increasing subsequence.

Examples

Input
nums = [1,3,5,4,7]
Output
3

[1,3,5] has length 3.

Constraints

  • 1 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9

Approaches

Check all subarrays.

CodeT: O(n^2) | S: O(1)

Track current length.

CodeT: O(n) | S: O(1)

Same approach.

CodeT: O(n) | S: O(1)

Complexity Comparison

Brute Force
T: O(n^2)S: O(1)

Check all subarrays.

Single Pass
T: O(n)S: O(1)

Track current length.

Single Pass Optimized
T: O(n)S: O(1)

Same approach.

Common Mistakes

Not handling all decreasing

Off-by-one in length

Not resetting current

Try It Yourself

Copy the optimal solution and run it in our compiler.

Open in Compiler