题解 | #字符统计#
字符统计
https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
# 思路:活用lambda函数进行多项排序
s = input() l = [] for i in set(s): l.append((i,s.count(i))) l.sort(key=lambda x:(-x[1],x[0])) for i in l: print(i[0],end="")
字符统计
https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
s = input() l = [] for i in set(s): l.append((i,s.count(i))) l.sort(key=lambda x:(-x[1],x[0])) for i in l: print(i[0],end="")
相关推荐