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

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

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

while True:
    try:
        string = input()
        dictionary = {}
        for i in string:
            if i not in dictionary:
                dictionary[i] = 1
            else:
                dictionary[i] += 1
        min_num = sorted(dictionary.values())[0]
        nlist = []
        for i in dictionary.keys():
            if dictionary[i] == min_num:
                nlist.append(i)
        result = ''
        for i in string:
            if i in nlist:
                continue
            else:
                result += i
        print(result)
    except EOFError:
        break
全部评论

相关推荐

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

创作者周榜

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