题解 | #字符统计#

import sys

for line in sys.stdin:
    data=line[:-1]
    counter={}
    for c in data:
        if c not in counter:
            counter[c]=1
        else:
            counter[c]+=1
            
    temp=list(counter.items())
    result=sorted(temp, key=lambda x : (x[1], -ord(x[0])), reverse=True)
    str_result=[]
    for c, _ in result:
        str_result.append(c)
    print(''.join(str_result))
全部评论

相关推荐

02-25 19:38
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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