#K80407. Most Frequent Character
Most Frequent Character
Most Frequent Character
You are given an integer \(n\) and a string \(s\) consisting of \(n\) characters. Your task is to determine the character that occurs most frequently in the string. In the event of a tie, choose the lexicographically smallest character.
Formally, let \(s = s_1s_2\ldots s_n\) be a string of length \(n\). Find the character \(c\) such that its frequency \(f(c)\) is maximized. If there exist multiple characters with the same maximum frequency, output the one with the smallest ASCII value.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains an integer \(n\), the length of the string.
- The second line contains the string \(s\) of length \(n\).
outputFormat
Output a single character which is the most frequently occurring character in the string. If there is a tie, output the lexicographically smallest character.
## sample6
bbaacc
a