문제
알파벳 소문자로만 이루어진 단어 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 = ' ')
'ALGORITHMS > DS Problems' 카테고리의 다른 글
프로그래머스 LEVEL3: 베스트앨범 (0) | 2022.01.06 |
---|---|
프로그래머스 - 더 맵게 (Heap) (0) | 2021.12.15 |
프로그래머스 기능개발 (스택/큐) (0) | 2021.12.15 |