-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoddmanout.java
56 lines (37 loc) · 924 Bytes
/
oddmanout.java
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
46
47
48
49
50
51
52
53
54
55
56
import java.util.ArrayList;
import java.util.Scanner;
public class oddmanout {
public static boolean repeated(int a, ArrayList<Integer> b)
{
int counter = 0;
for(int i=0; i < b.size(); i++)
{
if(b.get(i) == a) counter++;
}
return counter > 1;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int cases = scan.nextInt();
scan.nextLine();
for(int j=0; j < cases; j++)
{
int people = scan.nextInt();
scan.nextLine();
ArrayList<Integer> guest = new ArrayList<>(people);
for(int i=0; i < people; i++)
{
guest.add(scan.nextInt());
}
for(int i=0; i < people; i++)
{
if(!repeated(guest.get(i), guest))
{
System.out.println("Case #" + (j+1) + ": " + guest.get(i));
}
}
scan.nextLine();
}
scan.close();
}
}