updated at 2022. 12. 18. 오전 1:48:32
This commit is contained in:
@@ -1,20 +1,10 @@
|
|||||||
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/120956#
|
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/120956#
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
class Solution {
|
class Solution {
|
||||||
public int solution(String[] babbling) {
|
public int solution(String[] babbling) {
|
||||||
int answer = 0;
|
int answer = 0;
|
||||||
String[] able = {"aya","ye","woo","ma"};
|
|
||||||
int[] ablei = {2,3,4,5,6,7,8,10};
|
|
||||||
for(String b : babbling){
|
for(String b : babbling){
|
||||||
int blen = b.length();
|
if(b.matches("^(aya(?!aya)|ye(?!ye)|woo(?!woo)|ma(?!ma))+$")) answer ++;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user