

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 200 点
問題文
英小文字からなる文字列 S が与えられます。S に最も多く出現する文字を求めてください。そのような文字が複数ある場合は、そのうちアルファベット順で最も早いものを答えてください。
制約
- 1 \leq |S| \leq 1000(|S| は文字列 S の長さ)
- S の各文字は英小文字である。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S に最も多く出現する文字のうちアルファベット順で最も早いものを出力せよ。
入力例 1
frequency
出力例 1
e
frequency
には e
が 2 回出現し、これは他のどの文字よりも多いため e
を出力します。
入力例 2
atcoder
出力例 2
a
atcoder
には a
, t
, c
, o
, d
, e
, r
が 1 回ずつ出現するため、このうちアルファベット順で最も早い a
を出力します。
入力例 3
pseudopseudohypoparathyroidism
出力例 3
o
Score: 200 points
Problem Statement
You are given a string S consisting of lowercase English letters. Find the character that appears most frequently in S. If multiple such characters exist, report the one that comes earliest in alphabetical order.
Constraints
- 1 \leq |S| \leq 1000 (|S| is the length of the string S.)
- Each character in S is a lowercase English letter.
Input
The input is given from Standard Input in the following format:
S
Output
Among the characters that appear most frequently in S, print the one that comes earliest in alphabetical order.
Sample Input 1
frequency
Sample Output 1
e
In frequency
, the letter e
appears twice, which is more than any other character, so you should print e
.
Sample Input 2
atcoder
Sample Output 2
a
In atcoder
, each of the letters a
, t
, c
, o
, d
, e
, and r
appears once, so you should print the earliest in alphabetical order, which is a
.
Sample Input 3
pseudopseudohypoparathyroidism
Sample Output 3
o