반응형
반응형
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;
}
}
옹알옹알
반응형
'Algorithm > Programmers' 카테고리의 다른 글
[C#]프로그래머스 131127 할인 행사 - Hide (1) | 2024.12.12 |
---|---|
[C#]프로그래머스 87390 n^2 배열 자르기 - Hide (1) | 2024.12.11 |
[C#]프로그래머스 42747 H-Index - Hide (1) | 2024.12.03 |
[C#]프로그래머스 12949 행렬의 곱셈 - Hide (0) | 2024.12.01 |
[C#]프로그래머스 42840 모의고사 - Hide (0) | 2024.11.30 |