forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe3456.java
More file actions
58 lines (39 loc) · 1.04 KB
/
swe3456.java
File metadata and controls
58 lines (39 loc) · 1.04 KB
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
57
import java.util.*;
public class swe3456 {
static Queue<Integer> Buffer_Q = new LinkedList<>();
static HashMap<Integer, Integer> Hm = new HashMap<>();
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int T = sc.nextInt();
int answer;
//테스트케이스
for(int t=0; t<T; t++) {
//초기화
int N = 3;
Buffer_Q.clear();
Hm.clear();
answer = 0;
//입력
answer = solution(N);
System.out.println("#" + (t+1) + " " + answer);
}
}
public static int solution(int N)
{
//입력
for(int i =0; i<N; i++)
{
Buffer_Q.offer(sc.nextInt());
}
while(!Buffer_Q.isEmpty())
{
Hm.put(Buffer_Q.peek(), Hm.getOrDefault(Buffer_Q.poll(), 0)+1);
}
for(int i : Hm.keySet())
{
if(Hm.get(i) % 2 == 1)
return i;
}
return 0;
}
}