IBMOA #21
Find Length of Longest Bitonic Subarray
Estimated MediumJudge-ready
Topics (AI-labelled)DP BasicsTwo Pointers
Find the longest contiguous subarray whose elements are first non-decreasing and then non-increasing; either side may consist of only the peak element, and equal values are allowed.
Input
The first line contains n, and the second line contains n integers. 1≤n≤100000, 1≤element≤10^9.
Output
Output one integer, the answer.
Example 1
Input:
7
10 8 9 15 12 6 7
Output:
5
Example 2
Input:
6
5 1 2 1 4 5
Output:
3
Example 3
Input:
3
4 4 4
Output:
3
Example notes
The examples give 5, 3 and 3 respectively; equal elements may extend across the peak.
Editorial
Loading solution…