updated at 2022. 12. 18. 오전 1:48:32

This commit is contained in:
rl544
2022-12-18 01:48:32 +09:00
parent f17ece5636
commit b3a0e83649
+1 -11
View File
@@ -1,20 +1,10 @@
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/120956#
import java.util.*;
import java.util.stream.IntStream;
class Solution {
public int solution(String[] babbling) {
int answer = 0;
String[] able = {"aya","ye","woo","ma"};
int[] ablei = {2,3,4,5,6,7,8,10};
for(String b : babbling){
int blen = b.length();
if(IntStream.of(ablei).anyMatch(x -> x == blen)){
for(String c : able){
b = b.replaceFirst(c,"1");
}
if(b.matches("1+")) answer += 1;
} else continue;
if(b.matches("^(aya(?!aya)|ye(?!ye)|woo(?!woo)|ma(?!ma))+$")) answer ++;
}
return answer;
}