Dsa
Strings
Hard
Letter Frequency Sort
Given a string, sort its characters by frequency in descending order. Characters with the same frequency should appear in their original order. Your task is to read a string and output the characters sorted by their frequency.
Input Format:
- A single line containing the input string.
Output Format:
- The characters sorted by frequency, concatenated into a single string.
Example:
Input:
aabbccccd
Output:
cccbbaad
Key concepts
stringssortingfrequency
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