题解 | #名字的漂亮度#

名字的漂亮度

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)

全部评论

相关推荐

06-02 15:17
门头沟学院 Java
心爱的idea:怎么会呢 应该是打招呼有问题 问就说实习6个月全国可飞随时到岗
点赞 评论 收藏
分享
醉蟀:你不干有的是人干
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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