AcWing 64. 字符流中第一个只出现一次的字符
原题链接
困难
作者:
Scathon
,
2021-03-23 20:21:50
,
所有人可见
,
阅读 410
class Solution{
public:
map<char, int> cnt;
queue<char> chs;
//Insert one char from stringstream
void insert(char ch){
if (++cnt[ch] > 1) while (!chs.empty() && cnt[chs.front()] > 1) chs.pop();
else chs.push(ch);
}
//return the first appearence once char in current stringstream
char firstAppearingOnce(){
if (chs.empty()) return '#';
else return chs.front();
}
};
//grygTgXnfNfwxFOfHVlRDGtIrnTpBVpVzbeJsuJMBOQzMetlPdFOuWhZoWjZUolrlibIuSWKzkjHUQhvWqztHXpAAiAeYnbFPvog