767.重構字符串

S = "aaabcdbbdcccf" lst = sorted(S, key=lambda x: S.count(x), reverse=True) lst
輸出:['c', 'c', 'c', 'c', 'a', 'a', 'a', 'b', 'b', 'b', 'd', 'd', 'f']

 

 



相關文章
相關標籤/搜索