-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindUnCoupleInteger.java
37 lines (33 loc) · 989 Bytes
/
FindUnCoupleInteger.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
import java.io.*;
import java.util.*;
/*
Given the input
1, 2, 3, 1, 2
your program should output:
3
*/
public class Solution {
private static void findUncoupled(String[] items) {
int output = 0;
for(String item : items) {
//XOR all integers leaving behind the uncoupled
output ^= Integer.parseInt(item);
}
System.out.println(output);
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
String line = "Start";
BufferedReader stream = new BufferedReader(new InputStreamReader(System.in));
while(true) {
try {
line = stream.readLine();
} catch(IOException e) {
break;
}
if(line == null) break;
String[] items = line.split(", ");
findUncoupled(items);
}
}
}a