题解 | #名字的漂亮度#
名字的漂亮度
https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
def Solution(name): hashtable = dict() result = 0 for s in name: if s in hashtable: hashtable[s] += 1 else: hashtable[s] = 1 for i in range(26, 0, -1): if hashtable: result += i * max(hashtable.values()) del hashtable[[k for k, v in hashtable.items() if v == max(hashtable.values())][0]] else: break return result length = int(input().strip()) names = [] for i in range(length): names.append(input().strip()) for name in names: print(Solution(name))