#include <unordered_map>
class Solution
{
public:
//Insert one char from stringstream
queue<char> q;
unordered_map<char,int >ump;
void Insert(char ch) {
q.push(ch);
ump[ch]+=1;
}
// return the first appearence once char in current stringstream
char FirstAppearingOnce() {
while(ump[q.front()]!=1)
{
q.pop();
if(q.empty())
{
return '#';
}
}
return q.front();
}
};



京公网安备 11010502036488号