题解 | #字符统计#

字符统计

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#
全部评论

相关推荐

小叮当411:应该是1-3个月吧
点赞 评论 收藏
分享
05-21 15:47
门头沟学院 Java
浪漫主义的虹夏:项目有亮点吗,第一个不是纯玩具项目吗,项目亮点里类似ThreadLocal,Redis储存说难听点是花几十分钟绝大部分人都能学会,第二个轮子项目也没体现出设计和技术,想实习先沉淀,好高骛远的自嗨只会害了自己
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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