Algorithm


A. Spy Detected!
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array a consisting of n (n3�≥3) positive integers. It is known that in this array, all the numbers except one are the same (for example, in the array [4,11,4,4][4,11,4,4] all numbers except one are equal to 44).

Print the index of the element that does not equal others. The numbers in the array are numbered from one.

Input

The first line contains a single integer t (1t1001≤�≤100). Then t test cases follow.

The first line of each test case contains a single integer n (3n1003≤�≤100) — the length of the array a.

The second line of each test case contains n integers a1,a2,,an�1,�2,…,�� (1ai1001≤��≤100).

It is guaranteed that all the numbers except one in the a array are the same.

Output

For each test case, output a single integer — the index of the element that is not equal to others.

Example
input
Copy
4
4
11 13 11 11
5
1 4 4 4 4
10
3 3 3 3 10 3 3 3 3 3
3
20 20 10
output
Copy
2
1
5
3

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;

int main(){
  int t;
  cin>>t;
  int n;
  while(t--){
    cin>>n;
    int arr[n];
    for(int i = 0; i < n; i++){
      cin>>arr[i];
    }
    for(int i = 0; i < n; i++){
      if(i == 0 && arr[i] != arr[i+1] && arr[i] != arr[i+2] ){
        cout<<(i+1)<<endl;
        break;
      }
      if(i == 0 && arr[i] != arr[i+1] && arr[i] == arr[i+2] ){
        continue;
      }
      if(i == n-1){
        cout<<(i+1)<<endl;
        break;
      }
      if(arr[i] != arr[i+1] && arr[i] != arr[i-1]){
        cout<<(i+1)<<endl;
        break;
      }
    }
  }
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4
4
11 13 11 11
5
1 4 4 4 4
10
3 3 3 3 10 3 3 3 3 3
3
20 20 10

Output

x
+
cmd
2
1
5
3
Advertisements

Demonstration


Codeforcess solution 1512-A A. Spy Detected! ,C++, Java, Js and Python,1512-A,Codeforcess solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+