All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 23, 2024
Last updated : July 23, 2024
Related Topics : Array, Hash Table, Sorting
Acceptance Rate : 79.92 %
class Solution:
def frequencySort(self, nums: List[int]) -> List[int]:
cnt = Counter(nums)
return sorted([x for x in nums], key=lambda x: (cnt[x], -x))