class Solution
{
public:
int num[256];
int index;
Solution(){
for(int i = 0; i < 256; i++)
num[i] = -1;
index = 0;
}
//Insert one char from stringstream
void Insert(char ch)
{
if(num[ch] == -1)
num[ch] = index;
else if(num[ch] >= 0)
num[ch] = -2;
index++;
}
//return the first appearence once char in current stringstream
char FirstAppearingOnce()
{
int minIndex = INT_MAX;
char result = '#';
for(int i = 0; i < 256; i++){
if(num[i] >= 0 && num[i] < minIndex){
minIndex = num[i];
result = i;
}
}
return result;
}
};