题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
http://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
while True:
try:
words = list(map(str,input()))
dic_words={}
new_words = ''
for word in words:
if word not in dic_words:
dic_words[word]=1
else:
dic_words[word]+=1
min_value = min(dic_words.values())
for word in words:
if dic_words[word]>min_value:
new_words+=word
print(new_words)
except:
break
读懂题意很重要,读错了两次。
- dictionary 的用法 min(dic_words.values())可以得到value最小值
- 字符串用法