
https://school.programmers.co.kr/learn/courses/30/lessons/120869


def solution(spell, dic):
for d in dic:
if not set(spell) - set(d):
return 1
return 2
if 문에서 set 연산 결과가 0 이 나오면 (차집합의 결과가 0 이면 전부 있다는 뜻) not 을 통해 if 문을 실행시키며 즉시 1 을 반환한다.def solution(spell, dic):
answer = 0
n = len(spell)
for word in dic:
if len(word) != n:
continue
cnt = 0
word = list(set(word))
for i in word:
if i in spell:
cnt += 1
if cnt == n:
return 1
return 2
set 자료형에 대해서 더 알아가는 시간인것 같다.피드백은 언제나 환영입니다 :)