Problem Statment
You are given a sorted array containing only numbers 0 and 1. Find the transition point efficiently. The transition point is a point where "0" ends and "1" begins (0 based indexing).
Note:
- If there is no "1" exists, print -1.
- In case of all 1s print 0.
Expected Auxiliary Space: O(1).
Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. First Line of each test case contains N (number of elements in array). Second line contains N space seperated integers.
Output
Print Transition point or -1 for all 0s and 0 for all 1s.
Example 1:Input:
1
5
0 0 0 1 1
Output:
3
Example 2:Input:
1
4
0 0 0 0
Output:
-1