#K45747. Most Frequent Character

    ID: 27822 Type: Default 1000ms 256MiB

Most Frequent Character

Most Frequent Character

Given a string s, your task is to determine the character that occurs most frequently in the string. If there are multiple characters with the same maximum frequency, you must return the lexicographically smallest one.

For example, for the string aabbbcc, the character 'b' appears most frequently, while for the string bbbaaa, both 'a' and 'b' occur three times; however, since 'a' is lexicographically smaller than 'b', the correct answer is 'a'.

If the input string is empty, the output should be an empty string.

You can express the frequency condition mathematically as follows: if f(c) is the frequency of character c in s, then the answer c* is given by

\( c* = \min \{ c \mid f(c)=\max_{d \in s} f(d) \} \)

inputFormat

The input consists of a single line containing the string s. The string may be empty. All characters in s are considered.

outputFormat

Output a single character which is the most frequent character in the string. In case of ties in frequency, output the lexicographically smallest one. If the input string is empty, output an empty string.

## sample
aabbbcc
b