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

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

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")

全部评论

相关推荐

05-14 20:34
门头沟学院 Java
窝补药贝八股:管他们,乱说,反正又不去,直接说680
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务