-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOngRE2.java
More file actions
38 lines (32 loc) · 1.13 KB
/
Copy pathOngRE2.java
File metadata and controls
38 lines (32 loc) · 1.13 KB
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
package study.algorithm;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class OngRE2 {
public static void main(String[] args) {
String[] bab2 = new String[]{"ayaye", "uuu", "yeye", "yemawoo", "ayaayaa"};
System.out.println(Solution.solution(bab2));
String[] bab3 = new String[]{"ayaaya"};
System.out.println(Solution.solution(bab3));
}
static class Solution {
public static int solution(String[] babbling) {
int answer = 0;
String[] arr = new String[]{"aya", "ye", "woo", "ma"};
for (String str : babbling) {
for (String s : arr) {
str = str.replaceAll(s+"{2,}", "k");
System.out.println("str : " + str +", now : " + s);
if (str.contains(s)) {
str =str.replaceAll(s,"");
}
}
if(str.length() == 0){
answer++;
System.out.println("Count Up!!");
};
}
return answer;
}
}
}