#K13886. Max Frequency Character

    ID: 24012 Type: Default 1000ms 256MiB

Max Frequency Character

Max Frequency Character

You are given an integer (N) and a string (s) of length (N) consisting only of lowercase English letters. Your task is to determine the character that appears the maximum number of times in the string. In the event of multiple characters having the same maximum frequency, return the lexicographically smallest one.

For example:

  • For input (N = 6) and (s = "geekss"), the output should be (e) because 'e' appears twice and is lexicographically smaller than 's' which also appears twice.
  • For input (N = 7) and (s = "abracad"), the output should be (a).

Note: All input is provided via standard input (stdin) and all output should be written to standard output (stdout).

inputFormat

The input consists of two lines:

  1. The first line contains a single integer (N), representing the length of the string.
  2. The second line contains the string (s) of length (N) composed of lowercase English letters.

outputFormat

Output a single line containing the character that appears most frequently in the string. In case of a tie, output the lexicographically smallest character.## sample

1
a
a

</p>