时间O(N) 空间O(n)
class Solution { public: //Insert one char from stringstream void Insert(char ch) { str += ch; mymap[ch]++; } //return the first appearence once char in current stringstream char FirstAppearingOnce() { for(auto x:str){ if(mymap[x] == 1) return x; } return '#'; } private: unordered_map<char,int> mymap; string str; };