题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
#include <iostream> #include <string> #include <map> #include <bits/stdc++.h> using namespace std; int main() { string in; while(cin>>in){ map<char, int> chs; for(auto ch:in) chs[ch]++; int cnt_min = chs[in[0]]; for(auto it:chs) if(cnt_min > it.second) cnt_min = it.second; for(auto ch:in) if(chs[ch]>cnt_min) cout << ch; } } // 64 位输出请用 printf("%lld")