Sort Characters by Frequency
Rebuild a string so the most frequent characters come first, with each character's copies kept together.
The problem
Implement Solution.frequencySort(s). Return a rearrangement of s where all copies of each character sit next to each other and the groups are ordered from the most frequent character to the least frequent. Characters with the same frequency may come in either order. Uppercase letters, lowercase letters and digits are different characters. For example, "tree" can return "eetr" or "eert". 1 <= len(s) <= 500000.
Starter code
class Solution:
def frequencySort(self, s):
passPublic examples
The input described abovegivesTrueThe input described abovegivesTrueThe input described abovegivesTrue
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
