Skip to content

Commit eb0d49f

Browse files
authored
Merge pull request #1681 from AlgorithmWithGod/LiiNi-coder
[20251215] PGM / LV2 / 모음사전 / 이인희
2 parents b9f3ce3 + cad1907 commit eb0d49f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
private static final char[] VOWELS = {'A','E','I','O','U'};
6+
private static List<String> dict;
7+
8+
public int solution(String word) {
9+
dict = new ArrayList<>();
10+
dfs("");
11+
12+
for(int i = 0; i < dict.size(); i++){
13+
if(dict.get(i).equals(word)){
14+
return i + 1;
15+
}
16+
}
17+
return 0;
18+
}
19+
20+
private void dfs(String cur){
21+
if(cur.length() > 0){
22+
dict.add(cur);
23+
}
24+
if(cur.length() == 5){
25+
return;
26+
}
27+
28+
for(int i = 0; i < 5; i++){
29+
dfs(cur + VOWELS[i]);
30+
}
31+
}
32+
}
33+
34+
```

0 commit comments

Comments
 (0)