-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPikachuEasy.java
48 lines (40 loc) · 944 Bytes
/
PikachuEasy.java
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
39
40
41
42
43
44
45
46
47
48
public class PikachuEasy {
public String check(String word) {
char[] charArray = word.toCharArray();
int point = 0;
while (point < charArray.length) {
if (charArray[point] == 'p' && charArray[point + 1] == 'i') {
point += 2;
}
else if (charArray[point] == 'k' && charArray[point + 1] == 'a') {
point+=2;
}
else if (charArray[point] == 'c' && charArray[point + 1] == 'h' && charArray[point + 2] == 'u') {
point+=3;
}
else {
return "NO";
}
}
return "YES";
}
public String check2(String word) {
String[] list = { "pi", "ka", "chu" };
while (word.length() > 0) {
boolean hit = false;
for (String str : list) {
if (word.startsWith(str)) {
word = word.substring(str.length());
hit = true;
}
}
if (hit == false) {
return "NO";
}
}
return "YES";
}
}
// Powered by FileEdit
// Powered by moj 4.17 [modified TZTester]
// Powered by CodeProcessor