BOJ - 1919 - 애너그램 만들기

Updated:

def solution():
    alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
                'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
                'w', 'x', 'y', 'z']

    a = str(input())
    b = str(input())

    aCnt = [0 for _ in range(26)]
    bCnt = [0 for _ in range(26)]

    for i in a:
        aCnt[alphabet.index(i)] += 1

    for i in b:
        bCnt[alphabet.index(i)] += 1

    ret = 0

    for i in range(26):
        ret += abs(aCnt[i] - bCnt[i])

    print(ret)
solution()

https://www.acmicpc.net/problem/1919

Categories:

Updated:

Leave a comment