题解 | #名字的漂亮度#

名字的漂亮度

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)

全部评论

相关推荐

昨天 23:23
复旦大学 Java
点赞 评论 收藏
分享
求个付费实习岗位:这种就是吃满时代红利又没啥技术水平,只能靠压力学生彰显优越感的老登,别太在意了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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