Given a sorted array of positive integers. Your task is to find whether an element exists in the array from where number of smaller elements is equal to number of greater elements.
The first line of input contains T denoting the no of test cases . Then T test cases follow. The first line of each test case contains an integer N and the next line contains N space separated array elements.
For each test case output the required equal point. If Equal Point appears multiple times in input array, print the index of its first occurrence. If Equal Point doesn't exists then print "-1" (without quotes).
1 <= T <= 30
1 <= N <= 105
1 <= Ai <= 1012
1 2 3 3 3 3
1 2 3 3 3 3 4 4
Testcase1: 2 is the element before which we have 1 element that is smaller than 2 and we have 1 element to its right which is greater than 2. Print index of 2.
Testcase2: There is no element as such so print -1
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.