본문 바로가기

ALGORITHMS/DS Problems

백준 10808 - 알파벳 개수

문제

알파벳 소문자로만 이루어진 단어 S가 주어진다. 각 알파벳이 단어에 몇 개가 포함되어 있는지 구하시오.

Input 

baekjoon

Output

1 1 0 0 1 0 0 0 0 1 1 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0

My Code

from collections import defaultdict
import string 
s = input()
def solution(s):
    ans = []
    dic = dict(zip(string.ascii_lowercase,[0]*26))
    for c in s:
        dic[c] += 1
    for i in dic.values():
        ans.append(i)
    return ans

ans = solution(s)
for i in ans:
    print(i, end = ' ')