题解 | #删除字符串中出现次数最少的字符#

删除字符串中出现次数最少的字符

https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9

words = list(input().lower())
d = {}
for i in words:
    d[i] = words.count(i)
s = min(d.values())
for i in d:
    if d[i] == s:
        while i in words:
            words.remove(i)
print(''.join(words))

先找出字符最少的元素进行删除

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务