Skip to content

Commit

Permalink
이슈 #395에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
1 parent 2b32bd3 commit 9de522f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Programmers/옹알이_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <string>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

const vector<string> validWords = {"aya", "ye", "woo", "ma"};

bool canPronounce(string word) {
for (const auto& valid : validWords) {
size_t pos;
while ((pos = word.find(valid)) != string::npos) {
word.replace(pos, valid.length(), " ");
}
}
word.erase(remove(word.begin(), word.end(), ' '), word.end());
return word.empty();
}

int solution(vector<string> babbling) {
int count = 0;
for (const auto& word : babbling) {
if (canPronounce(word)) {
count++;
}
}
return count;
}

0 comments on commit 9de522f

Please sign in to comment.