题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
x = str(input()) mp = [0 for _ in range(26)] for c in x: c = ord(c) - ord('a') mp[c] += 1 mi = int(999) for i in range(26): if mp[i] != 0: mi = min(mp[i], mi) for i in range(26): if mp[i] == mi: x = x.replace(chr(ord('a')+ i),'') print(x)
删除最小的数值的元素