본문 바로가기
python-algorithm

백준 1371 가장 많은 글자

by 무적김두칠 2021. 11. 2.

1
2
3
4
5
6
7
import sys
ans=[0]*26
s=sys.stdin.read()
for i in s:
    if i.islower(): ans[ord(i)-97]+=1
for i in range(len(ans)):
    if ans[i]==max(ans): print(chr(97+i),end='')
cs

ord와 chr함수를 이용해 아스키코드값으로 문자열 처리하는 방식입니다

반응형

'python-algorithm' 카테고리의 다른 글

백준 2745 진법 변환  (0) 2021.11.02
백준 2495 연속구간  (0) 2021.11.02
백준 20944 팰린드롬 척화비  (0) 2021.11.02
백준 20540 연길이의 이상형  (0) 2021.11.02
Hacker rank Find the Median  (0) 2021.10.28

댓글