当前位置:网站首页>删除字符串中出现次数最少的字符
删除字符串中出现次数最少的字符
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
边栏推荐
- redis-shake 使用中遇到的错误整理
- Node. JS ODBC connection PostgreSQL
- 使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群
- 控制结构(一)
- adobe illustrator 菜单中英文对照
- How to design a good API interface?
- Wechat applet customer service access to send and receive messages
- [backtrader source code analysis 18] Yahoo Py code comments and analysis (boring, interested in the code, you can refer to)
- Connect PHP to MSSQL via PDO ODBC
- 导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
猜你喜欢

导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)

Advantages, disadvantages and selection of activation function

API gateway / API gateway (II) - use of Kong - load balancing

Tun equipment principle

今日睡眠质量记录76分

G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction

Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list

regular expression

Mumu, go all the way

自主作业智慧农场创新论坛
随机推荐
Analysis of common storage types and FTP active and passive modes
调度系统使用注意事项
考试考试自用
Explanation of redis database (I)
Mysql database explanation (8)
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
控制结构(二)
重定向和请求转发详解
什么是CNAS认证?CNAS认可的软件测评中心有哪些?
Hj31 word inversion
el-tree实现只显示某一级复选框且单选
软件性能测试报告起着什么作用?第三方测试报告如何收费?
网站建设与管理的基本概念
推荐搜索 常用评价指标
群体智能自主作业智慧农场项目启动及实施方案论证会议
Openstack command operation
Example of time complexity calculation
kubernetes之常用Pod控制器的使用
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
Comparaison du menu de l'illustrateur Adobe en chinois et en anglais