Maximum length of bitonic subarray problem

Description :-

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 + 1] >= .. A[j – 1] > = A[j]. Write a code to find the maximum of length bitonic subarray.

 

Input format :-

The first line contains t number of test cases.

For each test case there is two lines of input, first line consisting of the integer N. Second line consisting N separate space positive integers.

 

Constraints :-

1 <= t <= 100

1 <= N <= 10^5

1 <= a[i] <= 10^6

 

Output format :-

Final output is t lines containing the maximum length of bitonic sub array  for each input test case.

 

Sample Input :-

3
5
2 1 3 2 1

6
12 4 78 90 45 23

8
3 5 2 9 50 75 60 12


Sample output :-

4

5

6

 

Explanation Button                                solution button

Comments

No comment yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us





Scroll Up