Algorithm/Programmers
[C#]프로그래머스 120956 옹알이 (1) - Hide
zz0zz9
2024. 12. 5. 22:54
반응형
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/120956
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
문제 요약
머쓱이의 조카가 발음할 수 있는 단어의 개수를 반환하는 함수 만들기
풀이
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class Solution {
public int solution(string[] babbling) {
int answer = 0;
List<string> list = babbling.ToList();
string[] mm = {"aya", "ye", "woo", "ma"};
for (int i = 0; i < list.Count; i++)
{
for (int j = 0; j < mm.Length; j++)
{
if (list[i].Contains(mm[j]))
{
list[i] = list[i].Replace(mm[j], " ");
}
}
list[i] = Regex.Replace(list[i], @"\s", "");
}
answer = list.Count(item => item == "");
return answer;
}
}
옹알옹알
반응형