Equal Point in Sorted Array
##### Submissions: 2770   Accuracy: 18.38%   Difficulty: Easy   Marks: 2

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.

Input:
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.

Output:
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).

Constraints:
1 <= T <= 100
1 <= N <= 107
1 <= Ai <= 1018

Example:
Input:

2
6
1 2 3 3 3 3
8
1 2 3 3 3 3 4 4

Output:
1
-1

Explanation:
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

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

Author: Shubham Joshi 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.

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

to report an issue on this page.