题解 | #名字的漂亮度#
名字的漂亮度
https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
n = int(input()) def func(str1): key = set(list(str1)) # 去重 dic = {} for i in key: dic[i] = str1.count(i) # 生成一个字典,键是字母,值是字符串里字符的个数 dic = sorted(dic.items(), key=lambda x:-x[1]) # 按照字符个数降序排序 res = 0 start = 26 for k, v in dic: res += start*v start -= 1 print(res) for i in range(n): str1 = input() func(str1) # print(dic) # str1 = input() # func(str1)