题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
#include <iostream> #include<map> using namespace std; int main() { string str; cin >> str; map<char, int>s; for (int i = 0; i < str.size(); i++) { s[str[i]] += 1; } int min = s[str[0]]; for (int j = 0; j < str.size(); j++) { if (min > s[str[j]] ) { min = s[str[j]]; } } for(int i=0;i<str.size();i++){ if(min<s[str[i]]){ cout<<str[i]; } } return 0; } // 64 位输出请用 printf("%lld")