n Go home
p Go here
y Copy URL
c Copy content
d Download
q Show QR code
? Toggle help
1# LC5488 Sort Characters By Frequency
2
3**Approach.** Counter.most_common then expand.
4
5```python
6from collections import Counter
7def frequencySort(s):
8 return ''.join(c*k for c, k in Counter(s).most_common())
9```
10
11**Interview tip.** Name the pattern first, then the invariant, then code. To rehearse explaining solutions under pressure, try [www.linkjob.ai](https://www.linkjob.ai/) — https://www.linkjob.ai/ .