当前位置:网站首页>删除字符串中出现次数最少的字符
删除字符串中出现次数最少的字符
2022-04-23 15:34:00 【叶宁夏昕】
描述
实现删除字符串中出现次数最少的字符,若出现次数最少的字符有多个,则把出现次数最少的字符都删除。输出删除这些单词后的字符串,字符串中其它字符保持原来的顺序。
数据范围:输入的字符串长度满足 1 \le n \le 20 \1≤n≤20 ,保证输入的字符串中仅出现小写字母
输入描述:
字符串只包含小写英文字母, 不考虑非法输入,输入的字符串长度小于等于20个字节。
输出描述:
删除字符串中出现次数最少的字符后的字符串。
示例1
输入:aabcddd
输出:aaddd
while True:
try:
s = input()
m = s.lower()
dic, res = {}, ''
if 1 <= len(m) <= 20:
for i in m:
if i not in dic:
dic[i] = 1
else:
dic[i] += 1
Min = min(dic.values())
for i in m:
if dic[i] != Min:
res += i
print(res)
except:
break
版权声明
本文为[叶宁夏昕]所创,转载请带上原文链接,感谢
https://blog.csdn.net/come_bn/article/details/124310919
边栏推荐
- cadence SPB17.4 - Active Class and Subclass
- 移动金融(自用)
- T2 icloud calendar cannot be synchronized
- Deep learning - Super parameter setting
- 山寨版归并【上】
- MySQL sync could not find first log file name in binary log index file error
- 通过 PDO ODBC 将 PHP 连接到 MySQL
- Baidu written test 2022.4.12 + programming topic: simple integer problem
- KNN, kmeans and GMM
- Differential privacy (background)
猜你喜欢
Knn,Kmeans和GMM
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
Functions (Part I)
Multitimer V2 reconstruction version | an infinitely scalable software timer
山寨版归并【上】
导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
Mysql连接查询详解
What if the server is poisoned? How does the server prevent virus intrusion?
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
群体智能自主作业智慧农场项目启动及实施方案论证会议
随机推荐
Deep learning - Super parameter setting
通过 PDO ODBC 将 PHP 连接到 MSSQL
Explanation of redis database (III) redis data type
About UDP receiving ICMP port unreachable
深度学习——超参数设置
el-tree实现只显示某一级复选框且单选
码住收藏▏软件测试报告模板范文来了
JVM-第2章-类加载子系统(Class Loader Subsystem)
MySQL query library size
JSON date time date format
adobe illustrator 菜单中英文对照
Nacos程序连接MySQL8.0+ NullPointerException
【AI周报】英伟达用AI设计芯片;不完美的Transformer要克服自注意力的理论缺陷
What if the package cannot be found
Independent operation smart farm Innovation Forum
Error: unable to find remote key "17f718f726"“
Redis cluster principle
网站建设与管理的基本概念
cadence SPB17. 4 - Active Class and Subclass
Modify the default listening IP of firebase emulators