#C7686. Longest Increasing Sequence by One
Longest Increasing Sequence by One
Longest Increasing Sequence by One
In this problem, you are given a series of test cases. For each test case, you are provided with an array of integers representing the heights of buildings in a straight line. Your task is to determine the length of the longest contiguous subsequence in which the heights increase by exactly one at each step. In other words, you need to find the maximum length of a subarray such that for every consecutive pair of elements (a_i) and (a_{i+1}), the relation (a_{i+1} = a_i + 1) holds. This problem tests your ability to efficiently scan arrays and track sequences under simple constraints.
inputFormat
The input is given from standard input (stdin). The first line contains an integer (T) representing the number of test cases. Each test case consists of two lines. The first line of a test case contains a single integer (N), the number of buildings. The second line contains (N) space-separated integers representing the heights of the buildings.
outputFormat
For each test case, output a single integer on a new line, the length of the longest contiguous subsequence where every consecutive building's height is exactly one greater than the previous one.## sample
3
7
3 4 5 1 2 6 7
5
1 2 3 4 5
6
10 11 12 1 2 3
3
5
3
</p>