[프로그래머스] 2018 윈터코딩 - 스킬트리



https://programmers.co.kr/learn/courses/30/lessons/49993 <- 문제 링크는 여길로

어려운 문제는 아니니 풀이도 간단하게

#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;
}

댓글

이 블로그의 인기 게시물

Unity - Dialogue 시스템을 구현할 때 유용한 무료 에셋

Unity - 메타 파일

Unity - 라이브러리 폴더