Solution Python - Verbose


  • 0
    F
    import collections
    class Solution:
        def frequencySort(self, s):
            c = collections.Counter()
            s_list = list(s)
            for char in s_list:
                c.update(char)
            sorted_list = c.most_common() 
            init_string=""
            for tup in sorted_list:
                init_string+=(tup[0]*tup[1])
            print(init_string)
            
            return init_string
    

Log in to reply
 

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