This website contains ALL LeetCode **Premium** problems for
**FREE!!**.

All leaked interview problems are collected from Internet.

All leaked interview problems are collected from Internet.

Given an unsorted array of integers, find the length of longest `continuous`

increasing subsequence (subarray).

**Example 1:**

Input:[1,3,5,4,7]Output:3Explanation:The longest continuous increasing subsequence is [1,3,5], its length is 3. Even though [1,3,5,7] is also an increasing subsequence, it's not a continuous one where 5 and 7 are separated by 4.

**Example 2:**

Input:[2,2,2,2,2]Output:1Explanation:The longest continuous increasing subsequence is [2], its length is 1.

**Note:**
Length of the array will not exceed 10,000.

b'

\n\n#### Approach #1: Sliding Window [Accepted]

\n

\n

'
**Intuition and Algorithm**

Every (continuous) increasing subsequence is disjoint, and the boundary of each such subsequence occurs whenever `nums[i-1] >= nums[i]`

. When it does, it marks the start of a new increasing subsequence at `nums[i]`

, and we store such `i`

in the variable `anchor`

.

For example, if `nums = [7, 8, 9, 1, 2, 3]`

, then `anchor`

starts at `0`

(`nums[anchor] = 7`

) and gets set again to `anchor = 3`

(`nums[anchor] = 1`

). Regardless of the value of `anchor`

, we record a candidate answer of `i - anchor + 1`

, the length of the subarray `nums[anchor], nums[anchor+1], ..., nums[i]`

; and our answer gets updated appropriately.

**Complexity Analysis**

- \n
- \n
Time Complexity: , where is the length of

\n`nums`

. We perform one loop through`nums`

. \n - \n
Space Complexity: , the space used by

\n`anchor`

and`ans`

. \n

\n

Analysis written by: @awice.

\n