Longest Mountain
A mountain is a contiguous stretch that strictly increases to a peak then strictly decreases, with length ≥ 3. Print the longest mountain's length (0 if none).
Input: the first line has N; the second line has N integers.
Output: the longest mountain length, or 0.
Constraints:
- 1 ≤ N ≤ 105
- |ai| ≤ 109
Sample Tests
Input 1
7 2 1 4 7 3 2 5
Output 1
5
Input 2
3 1 2 3
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.