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