1636. Sort Array by Increasing Frequency

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1636

class Solution:
    def frequencySort(self, nums: List[int]) -> List[int]:
        cnt = Counter(nums)
        return sorted(nums, key=lambda x: (cnt[x], -x))