Maximum value in a bitonic array
Submissions: 9510   Accuracy:

52.52%

  Difficulty: Easy   Marks: 2

Given an array of elements which is first increasing and then may be decreasing, find the maximum element in the array.
Note: If the array is increasing then just print then last element will be the maximum value.

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, the size of array, the second line of each test case contains N integers which are the array elements.

Output:
Print the maximum element in the array.

Constraints:
1 ≤ T ≤ 50
3 ≤ N ≤ 106
1 ≤ Ai ≤ 106

Example:
Input:
2
9
1 15 25 45 42 21 17 12 11
5
1 45 47 50 5

Output:
45
50

Explanation:
Testcase 1: Maximum element is 45 which is present at bitonic point.

** 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.