#K861. Most Frequent Character
Most Frequent Character
Most Frequent Character
You are given a string s
. Your task is to determine the character that appears most frequently in the string. In the event that multiple characters have the same maximum frequency, you should output the lexicographically smallest character among them. Note that if the string is empty, you should output an empty string.
Formally, let \( f(c) \) denote the frequency of the character \( c \) in the string \( s \). You need to find the character \( c^* \) such that: \[ c^* = \min \{ c \mid f(c) = \max_{x \in s} f(x) \} \] where the minimum is taken in lexicographical order. If \( s \) is empty, output an empty string.
inputFormat
The input consists of a single line containing the string s
. The string may contain spaces and punctuation. Read the entire input from standard input.
outputFormat
Output the most frequent character in the string s
to standard output. If the string is empty, output an empty string.
abracadabra
a