题解 | #删除字符串中出现次数最少的字符#

删除字符串中出现次数最少的字符

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;
    }

}

全部评论

相关推荐

08-17 14:34
门头沟学院 Java
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务