题解 | #名字的漂亮度#

名字的漂亮度

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)

全部评论

相关推荐

况世奇才:我七月投的Java,面试官说搞大数据的,挂个Java的吸引进来投简历的,已经offer评估了看看能不能泡出来吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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