Short Python


  • 0
    class Solution(object):
        def frequencySort(self, s):
            freq = collections.defaultdict(int)
            for c in s:
                freq[c] += 1
            res = ""
            for t in sorted(freq.items(), key=lambda x:x[1], reverse=True):
                res += t[0]*t[1]
            return res

Log in to reply
 

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