-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
LonelyInteger.java
39 lines (34 loc) · 972 Bytes
/
LonelyInteger.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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int lonelyinteger(int[] a) {
int count[] = new int[101];
int item;
for(int i=0;i<a.length;i++){
count[a[i]]++;
}
for(int i=0;i<101;i++){
if(count[i]%2!=0)
return i;
}
return 0;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int res;
int _a_size = Integer.parseInt(in.nextLine());
int[] _a = new int[_a_size];
int _a_item;
String next = in.nextLine();
String[] next_split = next.split(" ");
for(int _a_i = 0; _a_i < _a_size; _a_i++) {
_a_item = Integer.parseInt(next_split[_a_i]);
_a[_a_i] = _a_item;
}
res = lonelyinteger(_a);
System.out.println(res);
}
}