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

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

https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9

#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define endl '\n'
#define int long long
#define double long double
#define mod 998244353
int read() {char act = 0;int f = 1, x= 0;while (act = getchar(), act < '0' && act != '-');if (act == '-') f = -1, act = getchar();x = act - '0';while (act = getchar(), act >= '0') x = x * 10 + act - '0';return x * f;}
void solve(){
    string s;
    cin>>s;
    map<char,int>mp;
    int minn=1e9;
    for(auto i:s){
        mp[i]++;
    }
    for(auto i:s){
        minn=min(mp[i],minn);
    }
    //cout<<minn<<endl;
    for(auto i:s){
        if(mp[i]!=minn)cout<<i;
    }
}
signed main()
{
    IOS; 
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-07 14:00
不想多说了,什么逆天HR,还要教我礼貌😂
机械打工仔:这不纯傻卵吗,他还操心上别人老板了
投递BOSS直聘等公司7个岗位
点赞 评论 收藏
分享
06-20 21:22
已编辑
门头沟学院 Java
纯真的河老师在喝茶:答应了就跑啊,实习随便跑啊,别被pua了,md就是找个廉价劳动力,还平稳过度正式工,到时候跟你说没转正
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 11:15
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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