题解 | #字符统计#

字符统计

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

python3

while True:
    try:
        strs = input()
        new_str = set(strs)
        res = {}
        for i in new_str:
            count_i = strs.count(i)
            if count_i not in res:
                res[count_i] = [i]
            else:
                res[count_i].append(i)
                res[count_i] = sorted(res[count_i],key=lambda x:ord(x))
        result = sorted(res.items(),key=lambda k :k[0],reverse=True)
        print(''.join(''.join(i[1]) for i in result))
    except:
        break
全部评论

相关推荐

07-02 13:52
武汉大学 golang
骗你的不露头也秒
牛客87776816...:😃查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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