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

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

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

str = input()
dic = {}
res = ''

# set() 是为了减少循环次数
for s in set(str): 
    cnt = str.count(s)
    dic[s] = cnt
    
for d in str :
    idx = min(dic.values())
    if dic[d] != idx :
        res += d 
print (res)  

全部评论

相关推荐

葬爱~冷少:我当时都是上午刷力扣,下午背八股,有活给我先别急,没活就干自己的事情
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务