1 class Solution 2 { 3 public: 4 //Insert one char from stringstream 5 void Insert(char ch) 6 { 7 s+=ch; 8 m[ch]++; 9 } 10 //return the first appearence once char in current stringstream 11 char FirstAppearingOnce() 12 { 13 for(int i=0;i<s.size();i++){ 14 if(m[s[i]]==1) return s[i]; 15 } 16 return '#'; 17 } 18 private: 19 string s; 20 unordered_map<char,int> m; 21 };