题解 | #删除字符串中出现次数最少的字符#暴力求解不多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)

全部评论

相关推荐

哥_留个offer先:跟他说,你这个最好用c#,微软就用c#Java不适合这个项目
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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