Find the Longest Continuous Increasing Subsequence
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
# Find the Longest Continuous Increasing Subsequence
Given an integer array `nums`, return the length of its longest contiguous subarray in which every value is strictly greater than the value immediately before it.
Implement:
```text
longestContinuousIncreasingSubsequence(nums) -> integer
```
The selected elements must occupy consecutive indices. Equal adjacent values break an increasing run.
## Constraints
- `1 <= nums.length <= 200,000`
- `-10^9 <= nums[i] <= 10^9`
## Examples
### Example 1
```text
nums = [1, 3, 5, 4, 7]
output = 3
```
The longest strictly increasing contiguous subarray is `[1, 3, 5]`.
### Example 2
```text
nums = [2, 2, 2, 2, 2]
output = 1
```
Every equal adjacent pair breaks strict increase, so each run contains one element.
Quick Answer: Find the length of the longest strictly increasing contiguous run in an integer array. The prompt distinguishes a continuous subarray from a non-contiguous subsequence and makes equal-value behavior explicit for a deterministic linear scan.
Given an integer array nums, return the length of its longest contiguous subarray in which every value is strictly greater than the value immediately before it. The selected elements must occupy consecutive indices. Equal adjacent values break an increasing run.
Constraints
- 1 <= nums.length <= 200,000
- -10^9 <= nums[i] <= 10^9
- Adjacent values must be strictly increasing; equality breaks a run.
Examples
Input: ([1, 3, 5, 4, 7],)
Expected Output: 3
Explanation: The first source example has a length-three increasing prefix.
Input: ([2, 2, 2, 2, 2],)
Expected Output: 1
Explanation: The second source example confirms that equality breaks every run.
Hints
- The answer concerns consecutive indices.
- An equal adjacent pair has the same effect on a run as a decrease.
- Only the current run length and the best length so far are needed.