-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
33 lines (26 loc) ยท 709 Bytes
/
Main.java
File metadata and controls
33 lines (26 loc) ยท 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Implementation.prg84512;
import java.util.*;
public class Main {
public static void main(String[] args) {
Solution sol = new Solution();
System.out.println(sol.solution("I"));
}
}
class Solution {
List<String> list;
public int solution(String word) {
list = new ArrayList<>();
dfs(new StringBuilder());
Collections.sort(list);
return list.indexOf(word)+1;
}
void dfs(StringBuilder sb) {
if (sb.length() == 5) return;
for (int i = 0; i < 5; i++) {
sb.append("AEIOU".charAt(i));
list.add(sb.toString());
dfs(sb);
sb.setLength(sb.length()-1);
}
}
}