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

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

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

lis1 = list(input())#接收输入
dic1 = {x:lis1.count(x) for x in lis1}#生成字典记录每个字母多少个字符
n = min(dic1.items(), key= lambda x:x[1])[1]#找到最少的有多少个字符
dic1 = {key: value for key, value in dic1.items() if value == n}#删除对应的所有字母
lis1 = [x for x in lis1 if x not in dic1.keys()]#删除对应的所有字母
print(''.join(lis1))#打印

全部评论

相关推荐

陆续:不可思议 竟然没那就话 那就我来吧 :你是我在牛客见到的最美的女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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