Given an array A of N integers. The task is to find a peak element in it.
An array element is peak if it is not smaller than its neighbours. For corner elements, we need to consider only one neighbour.
Note: There may be multiple peak element possible, in that case you may return any valid index.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N. Then in the next line are N space separated values of the array.
For each test case output will be 1 if the index returned by the function is an index with peak element.
You don't have to take any input. Just complete the provided function peakElement() and return the valid index.
1 <= T <= 100
1 <= N <= 100
1 <= A <= 1000
1 2 3
Testcase 1: In the given array, 3 is the peak element.
Testcase 2: 4 is the peak element.
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.