#C14804. Character Frequency Count
Character Frequency Count
Character Frequency Count
You are given a string s through standard input. Your task is to compute the frequency of each character in the string. The counting is case-sensitive and every character, including spaces and punctuation, must be counted.
Formally, for a given string \( s \) with length \( n \), the frequency of a character \( c \) is defined as:
[ \text{count}(c) = \sum_{i=1}^{n} [s_i = c] ]
Your output should be a JSON object (dictionary) that maps each character to its count. The keys in your output must be sorted in increasing order according to their ASCII values.
inputFormat
The input consists of a single line which is the string s for which the counts need to be computed.
outputFormat
Output a JSON object (dictionary) representing the frequency count of each character in the input string. The keys in the JSON object must be sorted in increasing order by their ASCII codes. For example, if the input is Hello, World!
, the output should be:
{" ": 1, "!": 1, ",": 1, "H": 1, "W": 1, "d": 1, "e": 1, "l": 3, "o": 2, "r": 1}## sample
Hello, World!
{" ": 1, "!": 1, ",": 1, "H": 1, "W": 1, "d": 1, "e": 1, "l": 3, "o": 2, "r": 1}