Python Solution. Easy Peasy


  • 0
    E
    import collections
    class Solution(object):
        def frequencySort(self, s):
            freq = collections.Counter(s)
            result = []
            
            for char in sorted(freq, key=freq.get, reverse=True):
                for repeat in range(0, freq[char]):
                    result.append(char)
            
            return ''.join(result)
    
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.