Frequency Sort
Medium

Problem Statement

Given an array of integers, sort the array in increasing order based on the frequency of the numbers. If multiple numbers have the same frequency, sort them in increasing order.

Examples

1Example 1
Input:
{ "nums": [ 1, 1, 2, 2, 2, 3 ] }
Output:
[ 3, 1, 1, 2, 2, 2 ]
2Example 2
Input:
{ "nums": [ 2, 3, 1, 3, 2 ] }
Output:
[ 1, 2, 2, 3, 3 ]
3Example 3
Input:
{ "nums": [ -1, 1, -6, 4, 5, -6, 1, 4, 1 ] }
Output:
[ -1, 5, -6, -6, 4, 4, 1, 1, 1 ]
Loading...

Sign in to Run Code and Submit