题解 | #名字的漂亮度#
名字的漂亮度
https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
from collections import defaultdict def bt(inStr): cMap = defaultdict(lambda : 0) for i in inStr: cMap[i] += 1 # sort as list count = 0 curBtScore = 26 for k,v in sorted(cMap.items(), key=lambda x: x[1], reverse=True): count += v * curBtScore curBtScore -= 1 return count n = int(input()) for i in range(n): line = input() count = bt(line) print(count)