public int solution(String[] babbling) {
int answer = 0;
String[] words = {"aya", "ye", "woo", "ma"};
for (String bb : babbling) {
boolean containsDuplicate = false;
for (String word : words) {
if (bb.contains(word + word)) {
containsDuplicate = true;
break;
}
}
if (containsDuplicate) {
continue;
}
bb = bb.replaceAll("aya|ye|woo|ma", "");
if (bb.isEmpty()) {
answer++;
}
}
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/133499