#C12194. Most Frequent Character
Most Frequent Character
Most Frequent Character
You are given a string s
. Your task is to determine the most frequent alphabetic character in the string. The character count is case‐insensitive and non-alphabetic characters are ignored. In case of a tie (i.e., two or more characters having the same highest frequency), output the character that appears first in the string (when the string is converted to lower-case).
For example, given the string aabbcc
, the characters 'a', 'b', and 'c' all appear twice, but 'a' appears first, so the output should be a
.
If the string is empty or has no alphabetic characters, output an empty string.
In mathematical terms, if we let \( f(c) \) be the frequency of character \( c \) (considering \( c \) in lowercase), then the result is the first character \( c \) in the order of appearance in \( s \) such that \( f(c) = \max\{f(x): x \in \text{alphabetic characters in } s\} \).
inputFormat
The input consists of a single line string s
. The string may contain spaces, punctuation, or other non-alphabetic characters. Input is read from standard input (stdin).
outputFormat
Output a single character — the most frequent alphabetic character in lowercase. If no alphabetic character exists, output an empty string. Output should be written to standard output (stdout).
## sampleaabbcc
a