하루일문
[백준] 20291번 파일 정리 (파이썬) 본문
풀이
import sys
n = int(sys.stdin.readline())
file_li = []
for i in range(n):
file = sys.stdin.readline().strip()
file_li.append(file[file.find(".") + 1:])
from collections import Counter
file_li = Counter(file_li).most_common()
file_li = sorted(file_li)
for _ in file_li:
print(*_)
해설
find로 . 위치를 찾아주었다.
'algorithm > baekjoon' 카테고리의 다른 글
[백준] 1764번 듣보잡 (파이썬) (0) | 2023.02.15 |
---|---|
[백준] 1822번 차집합 (파이썬) (0) | 2023.02.15 |
[백준] 1302번 베스트셀러 (파이썬) (0) | 2023.02.14 |
[백준] 14227번 소트인사이드 (파이썬) (0) | 2023.02.14 |
[백준] 10816번 숫자 카드 2(파이썬) (1) | 2023.02.14 |