题解 | #字符统计#

字符统计

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

list1=list(input())
list1.sort()
list2=[]

#print(list1)   ['a', 'a', 'c', 'c', 'c', 'd', 'd', 'd']

for i in list1:
    if i not in list2: list2.append(i)
    else: continue
#print(list2)   ['a', 'c', 'd']
    
list3=[]   
for i in list2:
    list4=[]
    list4.append(i)
    list4.append(list1.count(i))
    list3.append(list4)
    
#print(list3)   [['a', 2], ['c', 3], ['d', 3]]
list3.sort(key=lambda x:x[1],reverse=True)

for i in list3:
    print(i[0],end='')
#华为od#
全部评论

相关推荐

09-19 13:59
门头沟学院 Java
用微笑面对困难:Trae一下,如果真成了,他用了直接发字节起诉代码版权,,这个代码不商用是没问题的如果没成也是情理之中的。
点赞 评论 收藏
分享
10-02 19:29
已编辑
浙江科技大学 运营
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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