Search⌘ K
AI Features

Solution: Sort Array by Increasing Frequency

Understand how to solve frequency-based sorting problems by tracking value counts with a frequency map. Learn to use Python's Counter and a custom sort key to order array elements by ascending frequency and descending value efficiently.

Statement

Given an array of integers nums, sort the array in increasing order based on the frequency of each value. If multiple values share the same frequency, sort those values in decreasing order.

Return the sorted array.

Constraints:

  • 11 \leq nums.length 100\leq 100

  • 100-100 \leq ...