C++/代码/Hashmap
class Solution { public: //Insert one char from stringstream unordered_map<char,int> mmap; string s; void Insert(char ch) { s += ch; mmap[ch]++; } //return the first appearence once char in current stringstream char FirstAppearingOnce() { for (char c : s) if (mmap[c] == 1) return c; return '#'; } };