#include<unordered_map>
#include<queue>
using namespace std;
class Solution
{
public:
queue<char> q;
unordered_map<char, int> um;
void Insert(char ch)
{
if (um.find(ch) == um.end())
q.push(ch);
um[ch]++;
}
char FirstAppearingOnce()
{
while (q.empty() == 0) {
char tmp = q.front();
if (um[tmp] == 1)
return tmp;
else
q.pop();
}
return '#';
}
};
转载请注明原文地址:https://blackberry.8miu.com/read-2380.html