KotlinAlgorithm#22 (POG 옹알이(1))

박채빈·2023년 7월 19일
0

KotlinAlgorithm

목록 보기
22/28
post-thumbnail

POG 옹알이(1)

링크

코드

class Solution {
    fun solution(babbling: Array<String>): Int {
        var answer: Int = 0
        babbling.forEach { bab ->
            val split = bab.split("aya", "ye", "woo", "ma")
            if (split.none { it.isNotEmpty() }) answer += 1
        }
        return answer
    }

    fun solution1(babbling: Array<String>): Int =
        babbling.map { it.replace("aya|ye|woo|ma".toRegex(), "") }.count { it.isEmpty() }
}
profile
안드로이드 개발자

1개의 댓글

comment-user-thumbnail
2023년 7월 19일

가치 있는 정보 공유해주셔서 감사합니다.

답글 달기