当前位置:网站首页>删除字符串中出现次数最少的字符
删除字符串中出现次数最少的字符
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
边栏推荐
- 自动化测试框架常见类型▏自动化测试就交给软件测评机构
- TLS / SSL protocol details (30) RSA, DHE, ecdhe and ecdh processes and differences in SSL
- JSON date time date format
- ICE -- 源码分析
- 码住收藏▏软件测试报告模板范文来了
- 函数(第一部分)
- Openstack theoretical knowledge
- Special analysis of China's digital technology in 2022
- Knn,Kmeans和GMM
- Sword finger offer (1) -- for Huawei
猜你喜欢
考试考试自用
MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
What if the server is poisoned? How does the server prevent virus intrusion?
Mumu, go all the way
Tun model of flannel principle
[leetcode daily question] install fence
【AI周报】英伟达用AI设计芯片;不完美的Transformer要克服自注意力的理论缺陷
Sword finger offer (2) -- for Huawei
网站压测工具Apache-ab,webbench,Apache-Jemeter
Tun equipment principle
随机推荐
Baidu written test 2022.4.12 + programming topic: simple integer problem
Hj31 word inversion
GFS distributed file system (Theory)
setcontext getcontext makecontext swapcontext
函数(第一部分)
fatal error: torch/extension. h: No such file or directory
Use of common pod controller of kubernetes
What if the server is poisoned? How does the server prevent virus intrusion?
MySQL query library size
导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
Explanation 2 of redis database (redis high availability, persistence and performance management)
Error: unable to find remote key "17f718f726"“
Deep learning - Super parameter setting
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
编译,连接 -- 笔记
c语言---字符串+内存函数
Multitimer V2 reconstruction version | an infinitely scalable software timer
通過 PDO ODBC 將 PHP 連接到 MySQL
tcp_ Diag kernel related implementation 1 call hierarchy
Summary of interfaces for JDBC and servlet to write CRUD