字符串处理 哈希表。
#include <unordered_map>
class Solution
{
public:
//Insert one char from stringstream
string s;
unordered_map<char, int> mp;
void Insert(char ch) {
s += ch;
mp[ch]++;
}
//return the first appearence once char in current stringstream
char FirstAppearingOnce() {
for(int i = 0; i < s.length(); i++){
if(mp[s[i]] == 1){
return s[i];
}
}
return '#';
}
};