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

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

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

全部评论

相关推荐

07-29 14:37
门头沟学院 Java
点赞 评论 收藏
分享
Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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