#K546. Longest Positive Subarray
Longest Positive Subarray
Longest Positive Subarray
You are given the temperature recordings for n days. Your task is to determine the length of the longest contiguous subarray where every temperature is a positive integer.
In other words, you need to compute the maximum number of consecutive days where the temperature is strictly greater than 0. Formally, if the temperatures array is \(T = [t_1, t_2, \dots, t_n]\), you need to find the largest integer \(L\) such that there exists some index \(i\) with \(t_i > 0, t_{i+1} > 0, \dots, t_{i+L-1} > 0\). If no positive temperature exists, the answer is 0.
inputFormat
The first line of input contains a single integer \(n\) representing the number of days.
The second line contains \(n\) space-separated integers representing the temperatures recorded on each day.
outputFormat
Output a single integer, the length of the longest contiguous subarray where every temperature is positive.
## sample7
-1 2 3 5 -2 4 6
3