请实现一个函数用来找出字符流中第一个只出现一次的字符
字符流中第一个不重复的字符
http://www.nowcoder.com/questionTerminal/00de97733b8e4f97a3fb5c680ee10720
时间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;
};