题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
// HJ23-3 删除字符串中出现次数最少的字符.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 #include<iostream> #include<bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { map<char, int>mm; for (int i = 0; i < s.size(); i++) { mm[s[i]]++; } int len = s.size(); for (auto x : mm) { len = min(x.second, len); } for (auto c : s) { if (mm[c] == len)continue; cout << c; } cout << endl; } return 0; }