-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoUnique.java
More file actions
33 lines (31 loc) · 1.04 KB
/
TwoUnique.java
File metadata and controls
33 lines (31 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
/**
* Created by MalhotR1 on 04/28/2017.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
public class TwoUnique {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine().trim());
for (int t = 0; t < T; t++) {
String[] in = br.readLine().trim().split(" ");
long[] arr = new long[in.length];
for (int i = 0; i < in.length; i++) {
arr[i] = Long.parseLong(in[i]);
}
Arrays.sort(arr);
for (int i = 1; i < arr.length;) {
if ((arr[i-1] ^ arr[i]) == 0) i += 2;
else {
if ((arr[i+1] ^ arr[i]) == 0)
System.out.print(arr[i-1] + " ");
else
System.out.print(arr[i] + " ");
i++;
}
}
}
}
}