题解 | #删除字符串中出现次数最少的字符#暴力求解不多mi

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

https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9?tpId=37&tags=&title=&difficulty=0&judgeStatus=0&rp=1&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37

dic_str={}
str=input()
ls=list(str)
ls_del=[]
for iword in str:
    if iword not in dic_str:
        dic_str[iword]=1
    else:
        dic_str[iword]+=1
min=999
for iword in dic_str:
    if dic_str[iword]<min:
        min=dic_str[iword]
for key in dic_str:
    if dic_str[key]==min:
        ls_del.append(key)
for index in range(-1,-1-len(ls),-1):
    if ls[index] in ls_del:
        del ls[index]
        ls.append('')

a=''.join(ls)
print(a)

全部评论

相关推荐

买蜜雪也用卷:我觉得应该没有哪个人敢说自己熟练使用git,代码分支一复杂还是得慢慢寻思一下的,不过基本的拉代码提交代码还有分支什么的是应该会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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