{
public:
//Insert one char from stringstream
queue<char> q;
map<char, int> mp;
void Insert(char ch)
{
if(!mp[ch]){//如果是第一次出现,加入队列中
q.push(ch);
}
mp[ch]++;//记录ch字符的个数
}
//return the first appearence once char in current stringstream
char FirstAppearingOnce()
{
while(!q.empty()){
char temp=q.front();
if(mp[temp]==1){//证明第一次出现,直接返回该字符
return temp;
}
else{//不是首个字母,那么就得出栈
q.pop();
}
}
return '#';//其他情况直接返回
}
};