-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspydetect.java
More file actions
45 lines (36 loc) · 976 Bytes
/
Copy pathspydetect.java
File metadata and controls
45 lines (36 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package RandomCF;
import java.util.Scanner;
public class spydetect {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int testcases = input.nextInt();
for(int i = 0; i<testcases; i++){
int numarr = input.nextInt();
int[] arr = new int[numarr];
for(int j = 0; j<numarr; j++){
arr[j] = input.nextInt();
}
System.out.println(indexer(numarr, arr));
}
}
public static int indexer(int numarr, int[] arr){
int count1 = 1;
int count2 = 0;
int num1 = arr[0];
int index = 1;
for(int k = 1; k<numarr; k++){
if(arr[k]==num1){
count1++;
}
else{
index = k+1;
count2++;
}
}
if(count1==1){
return 1;
}else{
return index;
}
}
}