题解 | #名字的漂亮度#

名字的漂亮度

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

n = int(input())
for i in range(n):
    s = input()
    l =[]
    res = []
    ans = 0
    for item in s:
        if item not in l:
            l.append(item)
    for j in l:
        res.append(s.count(j))
    res = sorted(res,reverse=True)
    for j in range(len(res)):
        ans += (26-j)*res[j]
    print(ans)

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 17:23
点赞 评论 收藏
分享
07-25 10:53
门头沟学院 Java
投递简历一星期多了,一直卡在第一个环节没进展是不是已经没戏了
Peter____G...:其他大厂都过了,甚至在字节实习了,但是莉莉丝简历依旧秒挂
投递莉莉丝游戏等公司8个岗位
点赞 评论 收藏
分享
06-10 23:36
已编辑
首都经济贸易大学 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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