#C4477. Character Frequency Analysis
Character Frequency Analysis
Character Frequency Analysis
You are given a list of strings. Your task is to compute the frequency of each alphabetical character across all strings. Note that:
- The comparison is case-insensitive; that is, 'A' and 'a' are considered the same.
- Only alphabetic characters (a-z and A-Z) should be counted; ignore digits, punctuation, and whitespace.
The output should be a JSON formatted dictionary with keys sorted in lexicographical order. Use LaTeX formatting for any formulas if needed. For example, if the input string is hello
, then the output should be: {"e":1,"h":1,"l":2,"o":1}
inputFormat
The first line of input contains an integer n denoting the number of strings. Each of the following n lines contains a string.
For example:
3 hello world leetcode
outputFormat
Output a single line: a JSON dictionary representing the frequency of each alphabetical character (all in lowercase), with keys in lexicographical order. For example, for the sample input above, the output should be:
{"c":1,"d":2,"e":4,"h":1,"l":4,"o":3,"r":1,"t":1,"w":1}## sample
1
hello
{"e":1,"h":1,"l":2,"o":1}