> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Longest Continuous Increasing Subsequence

> Tested Python solution for LeetCode 674 with 15 pytest cases. Generate a practice environment with lcpy.

LeetCode 674, [Easy](/catalog/easy). Topics: [Array](/catalog/topics/array). [View on LeetCode](https://leetcode.com/problems/longest-continuous-increasing-subsequence/description/).

Generate this problem as a practice environment: tested reference solution, 15 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 674   # by problem number
lcpy gen -s longest_continuous_increasing_subsequence   # by problem name
```

## 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]`.

### Examples

```
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.

```
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.

### Constraints

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

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_continuous_increasing_subsequence/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_continuous_increasing_subsequence/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
class Solution:
    # Time: O(n)
    # Space: O(1)
    def find_length_of_lcis(self, nums: list[int]) -> int:
        best = 1
        run = 1
        for i in range(1, len(nums)):
            if nums[i - 1] < nums[i]:
                run += 1
                best = max(best, run)
            else:
                run = 1
        return best
```

## Complexity

| Time | Space |
| - | - |
| O(n) | O(1) |

## Tags


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.