class Solution
{
public:
vector<char> v;
unordered_map<char, int> hash;
//Insert one char from stringstream
void Insert(char ch) {
v.push_back(ch);
hash[ch]++;
}
//return the first appearence once char in current stringstream
char FirstAppearingOnce() {
for (auto &i: v) if (hash[i] == 1) return i;
return '#';
}
};

京公网安备 11010502036488号