Dsa
Sorting
Easy
Unique Characters Sort
You are given a string consisting of lowercase letters. Your task is to sort the characters in the string based on the number of unique characters. Characters with the same frequency should be sorted alphabetically. Output the sorted characters as a single line.
Example:
Input:
aabbccccddeee
Output:
aabbcdeccccde
Key concepts
sortinguniquecharacters
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now