가장 많은 글자 성공
시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 | 128 MB | 7947 | 3022 | 2523 | 39.379% |
문제
영어에서는 어떤 글자가 다른 글자보다 많이 쓰인다. 예를 들어, 긴 글에서 약 12.31% 글자는 e이다.
어떤 글이 주어졌을 때, 가장 많이 나온 글자를 출력하는 프로그램을 작성하시오.
입력
첫째 줄부터 글의 문장이 주어진다. 글은 최대 50개의 줄로 이루어져 있고, 각 줄은 최대 50개의 글자로 이루어져 있다. 각 줄에는 공백과 알파벳 소문자만 있다. 문장에 알파벳은 적어도 하나 이상 있다.
출력
첫째 줄에 가장 많이 나온 문자를 출력한다. 여러 개일 경우에는 알파벳 순으로 앞서는 것부터 모두 공백없이 출력한다.
예제 입력 1 복사
english is a west germanic
language originating in england
and is the first language for
most people in the united
kingdom the united states
canada australia new zealand
ireland and the anglophone
caribbean it is used
extensively as a second
language and as an official
language throughout the world
especially in common wealth
countries and in many
international organizations
import sys
sentence = sys.stdin.read()
alph = 'abcdefghijklmnopqrstuvwxyz'
result = []
for i in alph:
result.append(sentence.count(i))
max_num = max(result)
for i in range(len(result)):
if max_num == result[i]:
print(chr(i+97), end='')
'코딩테스트 준비 > 백준' 카테고리의 다른 글
백준 10699번 파이썬 오늘 날짜 (0) | 2022.05.12 |
---|---|
백준 1764번 파이썬 듣보잡 (0) | 2022.05.11 |
백준 10867번 중복 빼고 정렬하기 (0) | 2022.05.09 |
백준 10988번 파이썬 팰린드롬인지 확인하기 (0) | 2022.05.06 |
백준 25083번 파이썬 새싹 (0) | 2022.05.04 |