删除字符串中出现次数最少的字符
删除字符串中出现次数最少的字符
http://www.nowcoder.com/questionTerminal/05182d328eb848dda7fdd5e029a56da9
单词和出现次数存入哈希表 -> 查找最小出现值 -> 查找相同次数单词 -> 删除
while True: try: strings = input().strip() temp = {} for i in strings: if temp.get(i): temp[i] += 1 else: temp[i] = 1 cnt = min(list(temp.values())) print('cnt:', cnt) print(temp) for key, val in temp.items(): if val == cnt: strings = strings.replace(key, '') print(strings) except: break