题解 | #字符统计#
字符统计
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#
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#