-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
💬 문제
https://school.programmers.co.kr/learn/courses/30/lessons/84512
💬 Idea
- DFS로 순차 탐색을 진행하며 모음 사전의 순번을 dict에 저장한다.
💬 풀이
import Foundation
var wordDict: [String: Int] = [:]
var count = 0
func solution(word:String) -> Int {
dfs(words: [])
return wordDict[word]!
}
func dfs(words: [String]) {
wordDict[words.joined()] = count
if words.count == 5 {
return
} else {
for i in ["A", "E", "I", "O", "U"] {
count += 1
dfs(words: words + [i])
}
}
}