Last Updated: 27 Aug, 2025

Alphabetical Character Frequency

Easy
Asked in companies
HSBCAmdocs

Problem statement

You are given a string s. Your task is to calculate the frequency of each character present in the string and print the results.

The output must follow these specific rules:

1) The character counting is case-sensitive (e.g., 'a' and 'A' are considered different characters).
2) Any spaces (' ') in the input string must be ignored.
3) The final frequencies must be printed in alphabetical order of the characters.


Input Format:
The first line of input contains a single string s.


Output Format:
For each unique character (excluding spaces) found in the string, print a new line in the format: char: count

The lines must be sorted alphabetically by the character.


Note:
Alphabetical order refers to the standard character sort order (also known as ASCIIbetical order), where uppercase letters come before lowercase letters, and numbers/symbols have their own standard positions.