64,646
社区成员
发帖
与我相关
我的任务
分享
struct Num {
int index = 0;
int num = 0;
Num& operator++() {
++this->num;
return *this;
}
};
int firstUniqChar(string s) {
unordered_map<char, Num>m;
for (size_t i = 0; i < s.size(); ++i) {
++m[s[i]];
m[s[i]].index = i;
}
for (auto it = m.begin(); it != m.end(); ++it) {
cout << it->first << " " << it->second.num << endl;
}
return -1;
}