题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
#include <bits/stdc++.h> #include <map> using namespace std; int main() { map<int, int> cnt; string s; cin >> s; for(auto x : s){ cnt[x] += 1; } int mn = cnt.size(); for(auto m : cnt) mn = min(mn, m.second); for(auto p : s){ if(cnt[p] == mn) continue; cout << p; } }