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