BackeasySorting

Digit Distribution Sorting 2 Solution

Problem Statement

Given a list of integers, sort them based on the frequency of each digit (0-9) in the absolute value of each number. The frequency of each digit is counted, and numbers are sorted first by the highest frequency of any single digit and then by their numerical value in ascending order.

Example 1
Input
[123, 456, 789, 1011, 1213]
Output
[1011, 1213, 123, 456, 789]
Example 2
Input
[111, 222, 333, 444, 555]
Output
[111, 222, 333, 444, 555]
Example 3
Input
[9876, 5432, 1357, 6421, 7531]
Output
[1357,5432,6421,7531,9876]

Constraints

  • 1 <= N <= 10^5, where N is the number of elements in the input list.
  • 0 <= num <= 10^6, for any num in the input list.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free