#C8397. Longest Heat Wave
Longest Heat Wave
Longest Heat Wave
You are given a sequence of temperature readings. Your task is to determine the length of the longest "heat wave" in the sequence. A heat wave is defined as a contiguous subsequence where every temperature is exactly 1 greater than the previous one. Formally, given a sequence \(a_1, a_2, \dots, a_n\), you need to find the maximum length \(L\) such that for some index \(i\), \(a_{i+1} = a_i + 1, a_{i+2} = a_{i+1} + 1, \dots, a_{i+L-1} = a_{i+L-2} + 1\).
Note: If no consecutive increasing sequence is found, the answer is 1 (each individual temperature is considered a trivial heat wave).
inputFormat
The first line of input contains a single integer \(n\) representing the number of temperature readings. The second line contains \(n\) space-separated integers representing the temperature readings.
outputFormat
Output a single integer: the length of the longest heat wave (i.e. the longest contiguous subsequence where each temperature increases exactly by 1 compared to the previous reading).
## sample5
1 2 3 1 2
3