A mountain is a run of at least 3 consecutive values that strictly increases to a peak and then strictly decreases. Return the length of the longest mountain in arr, or 0 if there is none.
For [2, 1, 4, 7, 3, 2, 5] the answer is 5 ([1, 4, 7, 3, 2]).
Example 1
Input:
longest_mountain([2, 1, 4, 7, 3, 2, 5])
Output:
5
Example 2
Input:
longest_mountain([2, 2, 2])
Output:
0
0 <= len(arr) <= 2000000 <= arr[i] <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.