A,E,I,O,U 가 들어갈 경우를 전부 조회하면 된다. 다행히도 시초가 안난다
풀이를 다 찾아봤는데 DFS로 푼 코드중에는 꽤 괜찮은 코드 같다
private void dfs(String st, String word) {
if (st.length() > 5) return;
if (st.equals(word)) {
answer = depth;
return;
}
depth = depth + 1;
dfs(st + "A", word);
dfs(st + "E", word);
dfs(st + "I", word);
dfs(st + "O", word);
dfs(st + "U", word);
}
물론 AEIOU 를 전부 배열엔 넣고 for문으로 돌리면 되는데 뭔가 직관적이지 않아서 수정하였다