题解 | #字符统计#看不懂count(x)*1000的来看

字符统计

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

a = input()
a_list = list(a)

b_list = list(set(a_list))
b_list.sort()    # 提前把字符按ascii码顺序排列好,后面就只需要按字典的值排序一次就可以了

c_list = {}
for i in b_list:
    c_list[i] = a_list.count(i)
    
d_dict = dict(sorted(c_list.items(), key= lambda x: x[1], reverse=True))
e_list = list(d_dict.keys())
print(''.join(e_list))
全部评论

相关推荐

10-17 13:54
上海大学 运营
雾凇岛:这还说什么了,冲了兄弟们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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