forked from GreatAlgorithm-Study/AlgorithmStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYJ_49993.java
More file actions
38 lines (31 loc) · 933 Bytes
/
YJ_49993.java
File metadata and controls
38 lines (31 loc) · 933 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
34
35
36
37
38
import java.util.*;
public class YJ_49993 {
public static void main(String[] args) {
String skill = "CBD";
String[] skill_trees = {"BACDE", "CBADF", "AECB", "BDA"};
int answer = 0;
Map<Character,Integer> skillMap = new HashMap<>();
for(int i=0; i<skill.length(); i++){
skillMap.put(skill.charAt(i),i+1);
}
for(String tree :skill_trees){
boolean temp = true;
int order = 1;
for(int i=0; i<tree.length(); i++){
Integer now = skillMap.get(tree.charAt(i));
if(now == null){
continue;
}
if(now == order){
order++;
}else{
temp = false;
}
}
if(temp){
answer++;
}
}
System.out.println(answer);
}
}