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

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

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

import collections

# 先获取输入
words = input()

# 计算输入中每个字符出现的次数
word_num = collections.Counter(words)

# 遍历字符串 找到符合输出条件的字符
for item in words:
    # 如果遍历的字符的次数不是最小的,那么就输出该字符
    if word_num[item] != min(word_num.values()):
        print(item, end="")

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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