#C12093. Most Common Character Finder

    ID: 41482 Type: Default 1000ms 256MiB

Most Common Character Finder

Most Common Character Finder

Given a string s, determine the most frequent character within it. In the event that multiple characters have the same maximum frequency, return the one that appears first in the string.

Formally, if the frequency of a character c in s is denoted by \( f(c) \), then the answer is the character \( c^* \) satisfying \[ c^* = \min\{ c \in s : f(c) = \max_{x \in s} f(x) \} \] where the minimum is taken with respect to the order of appearance in s.

This problem tests your ability to perform simple frequency counts and handle tie-breaking based on order.

inputFormat

The input consists of a single line containing a non-empty string s.

outputFormat

Output a single character representing the most frequent character in the string. In case of a tie, output the character that appears first in the string.## sample

a
a