题目:原题链接(中等)

标签:哈希表、排序

解法 时间复杂度 空间复杂度 执行用时
Ans 1 (Python) O ( N l o g N ) O(NlogN) O(NlogN) O ( N ) O(N) O(N) 128ms (5.95%)
Ans 2 (Python)
Ans 3 (Python)

解法一(自定义排序):

class Solution:
    def frequencySort(self, s: str) -> str:
        count = collections.Counter(s)
        return "".join(sorted(s, key=lambda x: (count[x], x), reverse=True))