강의

멘토링

로드맵

Inflearn Community Q&A

minhyung01239529's profile image
minhyung01239529

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

9. Anagram (dictionary hash)

아나그램 풀이

Written on

·

209

0

안녕하세요. 강의 정말 잘 듣고 있습니다.

이번 문제에 대하여 dictionary의 value에 해당 문자열에 대하여 count함수를 써서 다음과 같이 풀어봤는데

괜찮은건가요?

 

import sys
# sys.stdin = open('input.txt','rt')

# 방법 1
a = input()
dict_a = dict()
for x in a:
    dict_a[x] = a.count(x)
b = input()
dict_b = dict()
for x in b:
    dict_b[x] = b.count(x)

if dict_a == dict_b:
    print('YES')
else:
    print('NO')
python코테 준비 같이 해요!

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

네. 잘하신 코드입니다.

minhyung01239529's profile image
minhyung01239529

asked

Ask a question