[프로그래머스] 2018 윈터코딩 - 스킬트리
어려운 문제는 아니니 풀이도 간단하게
#include <string>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
bool comp(string skill, string str) {
int current = 0;
for (int i = 0; i < str.size(); i++) {
for (int j = current; j < skill.size(); j++) {
if (skill[j] != str[i]) continue;
if (j != current) return false;
current++;
break;
}
}
return true;
}
int solution(string skill, vector<string> skill_trees) {
int answer = 0;
for (int i = 0; i < skill_trees.size(); i++) {
if (comp(skill, skill_trees[i])) answer++;
}
return answer;
}

댓글
댓글 쓰기