题解 | #字符统计#

字符统计

http://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0

while True:
    chars = []
    total = []
    ret = {}
    try:
        s = input()
    except EOFError:
        break
    for c in set(s):
        if c not in chars:
            chars.append(c)
            count = s.count(c)
            if count not in ret:
                ret[count] = [c]
                total.append(count)
            else:
                ret[count].append(c)
    total.sort(reverse=True)
    for i in total:
        ret[i].sort()
        for c in ret[i]:
            print(c, end='')
    print("")
全部评论

相关推荐

04-08 23:37
已编辑
东华大学 结构工程师
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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