Sort By Frequency

Programming Interview Medium 5 views
Back to Questions

Problem Description

For each testcase you get n integers. Sort them by frequency descending. If frequency same, smaller number first. Output sorted list.

Input Format

First integer t. For each: n then n integers.

Output Format

t lines sorted arrays.

Sample Test Case

Input:
1 10 1 1 2 2 2 3 3 4 5 5
Output:
2 2 2 1 1 3 3 4 5 5

Constraints

Sum of n over all testcases

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next