当前位置:网站首页>Deletes the least frequently occurring character in the string
Deletes the least frequently occurring character in the string
2022-04-23 15:40:00 【Ye Ningxia Xin】
describe
Delete the least frequent character in the string , If there are multiple characters with the least number of occurrences , Then delete the characters that appear the least . Output the string after deleting these words , The other characters in the string remain in the same order .
Data range : The length of the input string meets the requirements 1 \le n \le 20 \1≤n≤20 , Ensure that only lowercase letters appear in the input string
Input description :
String contains only lowercase letters , Illegal input is not considered , The length of the input string is less than or equal to 20 Bytes .
Output description :
Delete the string after the least frequent character in the string .
Example 1
Input :aabcddd
Output :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
版权声明
本文为[Ye Ningxia Xin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231534071384.html
边栏推荐
猜你喜欢
【Leetcode-每日一题】安装栅栏
携号转网最大赢家是中国电信,为何人们嫌弃中国移动和中国联通?
Multitimer V2 reconstruction version | an infinitely scalable software timer
群体智能自主作业智慧农场项目启动及实施方案论证会议
IronPDF for . NET 2022.4.5455
Configuration of multi spanning tree MSTP
Why disable foreign key constraints
Timing model: gated cyclic unit network (Gru)
CVPR 2022 优质论文分享
Functions (Part I)
随机推荐
What role does the software performance test report play? How much is the third-party test report charged?
Rsync + inotify remote synchronization
Upgrade MySQL 5.1 to 5.68
For examination
c语言---指针进阶
时序模型:门控循环单元网络(GRU)
Temporal model: long-term and short-term memory network (LSTM)
推荐搜索 常用评价指标
木木一路走好呀
MySQL Cluster Mode and application scenario
Treatment of idempotency
pgpool-II 4.3 中文手册 - 入门教程
ICE -- 源码分析
为啥禁用外键约束
CAP定理
一刷312-简单重复set-剑指 Offer 03. 数组中重复的数字(e)
Mysql database explanation (IX)
2022年中国数字科技专题分析
MySQL集群模式与应用场景
Openstack command operation