class Solution{
public:
unordered_map<char,int> count;
queue<int> q;
//Insert one char from stringstream
void insert(char ch){
if(++ count[ch] > 1) //当ch出现过时
{
while(q.size() && count[q.front()] > 1) q.pop(); //弹出队列中所有出现过不止一次的字母
}
else
q.push(ch); //加入没有出现过的字母
}
//return the first appearence once char in current stringstream
char firstAppearingOnce(){
if(q.empty()) return '#';
return q.front();
}
};