728x90
반응형
문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/120869
풀이:
from itertools import permutations
def solution(spell, dic):
res =[]
count = 0
for i in range(2,len(spell)+1):
for j in list(permutations(spell,i)):
res.append("".join(j))
for i in res:
if i in dic:
print(i)
count += 1
return 2 if count == 0 else 1
조합과 딕셔너리를 쓴 풀이
오늘 기준 테스트케이스 3번이 오타나옴
반응형
댓글