Dsa
Hashing
Easy
Character Frequency Analyzed
Write a program that takes in a string and counts the frequency of each character, ignoring spaces and considering uppercase and lowercase letters as the same. Output the character frequencies in descending order of frequency. If two characters have the same frequency, they should be sorted in alphabetical order.
Input format:
A single line containing the input string.
Output format:
A list of characters and their frequencies in the format (char: frequency) printed one per line.
Example:
Input:
Hello World
Output:
h: 1
l: 3
o: 2
r: 1
w: 1
e: 1
Key concepts
hashingstringsfrequency
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