103381: [Atcoder]ABC338 B - Frequency
Description
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
Output
分数:200分
问题描述
给你一个由小写英文字母组成的字符串$S$。找到$S$中出现最频繁的字符。如果有多个这样的字符,则报告按字母顺序最早出现的那个。
限制条件
- $1 \leq |S| \leq 1000$($|S|$表示字符串$S$的长度)。
- $S$中的每个字符都是小写英文字母。
输入
输入从标准输入按以下格式给出:
$S$
输出
在$S$中出现最频繁的字符中,打印按字母顺序最早出现的那个。
样例输入1
frequency
样例输出1
e
在frequency
中,字母e
出现两次,比其他任何字符都多,所以你应该打印e
。
样例输入2
atcoder
样例输出2
a
在atcoder
中,每个字母a
、t
、c
、o
、d
、e
和r
都出现一次,所以你应该打印字母顺序最早的那个,即a
。
样例输入3
pseudopseudohypoparathyroidism
样例输出3
o