题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
http://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
def get_ans(s):
dic={}
for i in s:
dic[i]=dic.get(i,0)+1
dic1=sorted(dic.items(),key=lambda d:d[1])
mark,ans=dic1[0][1],''
for i in s:
if dic[i]!=mark:
ans+=i
return ans
if __name__=='__main__':
import sys
lines = []
while True:
line = sys.stdin.readline().strip()
if line == "":
break
lines.append(line)
for item in lines:
print(get_ans(item))
题解-数据结构与算法 文章被收录于专栏
小菜鸟的题解