import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Solution {
public Solution() {
for(
int i =
0; i <
256; ++i) {
hashtable[i] = -
2;
}
}
private int[] hashtable =
new int[
256];
private int count =
0;
public void Insert(
char ch)
{
if(hashtable[ch] == -
2) {
hashtable[ch] = count++;
return;
}
if(hashtable[ch] != -
2 && hashtable[ch] != -
1) {
hashtable[ch] = -
1;
return;
}
}
public char FirstAppearingOnce()
{
int res = count;
int k =
0;
for(
int i =
0; i <
256; ++i) {
if(hashtable[i] != -
2 && hashtable[i] != -
1) {
if(res > hashtable[i]) {
res = hashtable[i];
k = i;
}
}
}
if(res == count)
return '#';
else return (
char)k;
}
public static void main(String[] args) {
Solution solution =
new Solution();
solution.Insert(
'g');
System.out.println(solution.FirstAppearingOnce());
}
}