-
[프로그래머스] 모음사전 - 파이썬(python)
나의 풀이 def dfs(x, dictionary, alpha): dictionary.append(x) for i in alpha : if len(x) != len(alpha) : dfs(x+i, dictionary, alpha) else : x[:-1] def solution(word): alpha = ['A','E','I','O','U'] dictionary = [] for i in range(len(alpha)) : dfs(alpha[i], dictionary, alpha) return dictionary.index(word) + 1 DFS 로 풀이한 문제이다. 먼저 dictionary 에 현재 나의 문자를 추가한다. 그리고, alpha 리스트를 반복문으로 돌면서, 문자열 x의 길이가 5 보다 작다..
알고리즘/완전탐색
2022. 9. 7.