当前位置:网站首页>删除字符串中出现次数最少的字符
删除字符串中出现次数最少的字符
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
- 【backtrader源码解析18】yahoo.py 代码注释及解析(枯燥,对代码感兴趣,可以参考)
- The life cycle of key value in redis module programming
- What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
- Mumu, go all the way
- Node.js ODBC连接PostgreSQL
- Deep learning - Super parameter setting
- 深度学习调参的技巧
- Mobile finance (for personal use)
- Basic concepts of website construction and management
猜你喜欢
API gateway / API gateway (II) - use of Kong - load balancing
网站建设与管理的基本概念
Today's sleep quality record 76 points
The wechat applet optimizes the native request through the promise of ES6
Multitimer V2 reconstruction version | an infinitely scalable software timer
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
函数(第一部分)
MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
携号转网最大赢家是中国电信,为何人们嫌弃中国移动和中国联通?
Krpano panorama vtour folder and tour
随机推荐
Demonstration meeting on startup and implementation scheme of swarm intelligence autonomous operation smart farm project
HJ31 单词倒排
API gateway / API gateway (II) - use of Kong - load balancing
Deep learning - Super parameter setting
码住收藏▏软件测试报告模板范文来了
JVM-第2章-类加载子系统(Class Loader Subsystem)
网站建设与管理的基本概念
Error: unable to find remote key "17f718f726"“
什么是CNAS认证?CNAS认可的软件测评中心有哪些?
控制结构(二)
For examination
Sword finger offer (2) -- for Huawei
【backtrader源码解析18】yahoo.py 代码注释及解析(枯燥,对代码感兴趣,可以参考)
Multitimer V2 reconstruction version | an infinitely scalable software timer
Node.js ODBC连接PostgreSQL
setcontext getcontext makecontext swapcontext
2022年中国数字科技专题分析
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
控制结构(一)
Explanation of redis database (IV) master-slave replication, sentinel and cluster