题解 | #名字的漂亮度#
名字的漂亮度
https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
n = int(input()) for i in range(n): s = input() score = 0 l1 = [] l2 = [] se = list(set(s)) ns = sorted(se, key=lambda c: -s.count(c)) # decs order for c in ns: l1.append(s.count(c)) for i in range(26): # full list of weight l2.append(26-i) for j in range(len(se)): score += l2[j] * l1[j] print(score)