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

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

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

import sys

s=input()
dict={}
goal=0
res=''
for i in s:
    if i in dict:
        dict[i]+=1
    else:
        dict[i]=1   #不可缺少,这是初始化dict的值
goal=min(dict.values())#字典的值
for i in s:
    if dict[i]!=goal:
        res+=i
print(res)


        

全部评论

相关推荐

不愿透露姓名的神秘牛友
01-07 00:20
ANONYMOUS0...:双9硕,大模型算法,总包1700w-2000w 刀了。 很有诚意,无签字费。已接。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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