Maximum length Bitonic Subarray
Submissions: 4887   Accuracy:

26.28%

  Difficulty: Medium   Marks: 4

Given an array A[0 … n-1] containing n positive integers, a subarray A[i … j] is bitonic if there is a k with i < k < j such that A[i] < A[i + 1] ... < A[k] > A[k + 1] > .. A[j – 1] >  A[j]. Write a program that returns the length of the maximum length bitonic subarray.

For Example: In array {20, 4, 1, 2, 3, 4, 2, 10} the maximum length bitonic subarray is {1, 2, 3, 4, 2} which is of length 5.

Note: A[k] can be first or last element. Ex:-  10 20 30 , 30 20 10 and 1 2 3 4 3 2 1 these all are bitonic array.

Input:

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N,N is the size of array.
The second line of each test case contains N input A[i].

Output:

Print the maximum length of bitonic subarray.

Constraints:

1 ≤ T ≤ 200
1 ≤ N ≤ 200
1 ≤ A[i] ≤ 1000

Example:

Input:
2
6
12 4 78 90 45 23
4
10 20 30 40

Output:
5
4

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.