题解 | #名字的漂亮度#

名字的漂亮度

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

stringlist=[]

n = int(input())
for i in range(n):
    stringlist.append(input())

for j in stringlist:
    sum = 0
    alphalist=[]
    countlist=[]
    for k in range(len(j)):
        if j[k] not in alphalist:
            alphalist.append(j[k])
            countlist.append(1)
        else:
            index = alphalist.index(j[k])
            countlist[index] += 1

    c = sorted(countlist,reverse=True)

    for l in range(len(countlist)):
        sum = sum + c[l]*(26-l)     
    print(sum)


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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