티스토리 뷰
https://programmers.co.kr/learn/courses/30/lessons/84512
[프로그래머스][C++] 모음사전
#include <string>
#include <vector>
using namespace std;
char mo[5] = { 'A','E','I','O','U' };
int answer = 0;
bool dfs(string word, string find) {
answer++;
if (!word.compare(find))
return true;
if (word.length() == 5)
return false;
for (int i = 0; i < 5; i++) {
if (dfs(word + mo[i], find))
return true;
}
return false;
}
int solution(string word) {
dfs("", word);
return answer - 1;
}
'Problem Solving' 카테고리의 다른 글
[leetcode][C++] sort colors (0) | 2021.10.15 |
---|---|
[leetcode][C++][Java] jump game (0) | 2021.10.15 |
[leetcode][C++] search in rotated sorted array (0) | 2021.10.06 |
[leetcode][C++] generate parentheses (0) | 2021.10.05 |
[leetcode][C++][Java] letter combinations of a phone number (0) | 2021.10.05 |
댓글