题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
dict = {}
str = input()
for i in str :
if i in dict:#如果字符i存在于字典中,则i对应的值+1,否则值为1
dict[i] += 1
else:
dict[i] = 1
Min = min(dict.values())#求出出现的最小次数
for i in str :
if str.count(i) == Min:
str = str.replace(i,'')
print(str)
#悬赏#
查看14道真题和解析
