103381: [Atcoder]ABC338 B - Frequency

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:11 Solved:0

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中,每个字母atcoder都出现一次,所以你应该打印字母顺序最早的那个,即a


样例输入3

pseudopseudohypoparathyroidism

样例输出3

o

HINT

输出字符串中出现次数最多的那个字母?数量相同输出小的字母?

加入题单

算法标签: