题解 | 名字的漂亮度

名字的漂亮度

https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3

s = int(input())
for i in range(s):
    dict1 = dict()
    for j in input():
        if dict1.get(j,0) ==0:
            dict1[j] = 1
        else:
            dict1[j]+=1
    dict1 = dict(sorted(dict1.items(),key=lambda x:x[1],reverse=True))
    # print(dict1)
    num =26
    sum = 0
    for key,value in dict1.items():
        sum = value*num+sum
        num -=1
    print(sum)

全部评论

相关推荐

LastWh1spe...:ssob真有些人和那个没睡醒一样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务