#C976. Longest Contiguous Increasing Subarray

    ID: 53888 Type: Default 1000ms 256MiB

Longest Contiguous Increasing Subarray

Longest Contiguous Increasing Subarray

Given an array of integers, your task is to determine the length of the longest contiguous subarray that is strictly increasing. In other words, you need to find the maximum length of a subarray \(A[i], A[i+1], \ldots, A[j]\) where \(A[k] < A[k+1]\) for every \(i \leq k < j\). If the array is empty, the result should be 0.

Example:

  • Input: [1, 2, 2, 3, 4, 1, 5, 6]
  • Output: 3

The problem can be formally stated as: given an array \(A = [a_1, a_2, \ldots, a_n]\), find the maximum \(L\) such that there exists an index \(i\) (\(1 \leq i \leq n - L + 1\)) with \(a_i < a_{i+1} < \dots < a_{i+L-1}\).

inputFormat

The first line contains an integer \(n\) that represents the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

Output a single integer: the length of the longest contiguous subarray that is strictly increasing.

## sample
8
1 2 2 3 4 1 5 6
3