-
[프로그래머스][Kotlin]옹알이(2)프로그래머스 2022. 11. 10. 19:13728x90
class Solution { fun solution(babbling: Array<String>): Int { var answer: Int = 0 val checkList = arrayOf<String>("aya", "ye", "woo", "ma") for(check in babbling){ var temp = check for(i in 0 .. checkList.size-1){ if(temp.contains(checkList[i]+checkList[i])){ continue } else { temp = temp.replace(checkList[i], " ") } } if(temp.replace(" ","") == "") answer++ } return answer } }
최적의 코드가 아닐 수 있으며, 현재 저의 실력으로 해결하였습니다.
'프로그래머스' 카테고리의 다른 글
과일장수 (0) 2022.11.11 햄버거 만들기 (0) 2022.11.11 2개 이하로 다른 비트 (0) 2022.10.31 연속 부분 수열 합의 개수 (0) 2022.10.27 H-Index (0) 2022.09.27