hackerrank.com
Company Logo
Problem link : https://www.hackerrank.com/challenges/most-commons/problem
Difficulty : Medium
Tip
- Don't forget we should sort as alphabet order if the occurrence is same
- To do sort, don't sort result
- we can sort input string like below
- Before sort : bbccaa
- After sort : aabbcc
- We should manage two things together, one is key(such as 'a') and the other is key's number of occurrence, dictionary is good to use
- Order should be sorted by its occurrence, and OrderedDict() is good to use
Solution