Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 799 Bytes

_1636. Sort Array by Increasing Frequency.md

File metadata and controls

32 lines (22 loc) · 799 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : July 23, 2024

Last updated : July 23, 2024


Related Topics : Array, Hash Table, Sorting

Acceptance Rate : 79.92 %


Solutions

Python

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))