#K33852. Maximum Occurrence of a Character
Maximum Occurrence of a Character
Maximum Occurrence of a Character
Given a string s, your task is to determine the character that appears the maximum number of times in the string. In the event of a tie, the character that appears first in the string (i.e. with the smallest index) should be chosen.
Mathematically, let \(f(c)\) denote the frequency of character \(c\) in \(s\). You are required to find a character \(k\) that satisfies:
[ k = \min { i \mid f(s_i) = \max_{c \in s} f(c) } ]
If the string is empty, output an empty string.
inputFormat
The input is provided via standard input (stdin) and consists of a single line containing the string s. The string may contain any printable characters, and its length can be zero or more.
outputFormat
Output the single character that occurs most frequently in the input string. In case of a tie, output the character that appears first in the string. If the input string is empty, output an empty string.
## sampleaabbbccde
b