https://programmers.co.kr/learn/courses/30/lessons/49993#fn1
코딩테스트 연습 - 스킬트리
programmers.co.kr
나의풀이
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(string skill, vector<string> skill_trees) {
int answer = skill_trees.size();
for (string str : skill_trees) {
auto index = find(str.begin(), str.end(), skill[0]);
for (int i = 1; i < skill.size(); i++) {
auto index_next = find(str.begin(), str.end(), skill[i]);
if (index > index_next) {
answer--;
break;
}
index = index_next;
}
}
return answer;
}
'전공공부 > 코딩테스트' 카테고리의 다른 글
(c++) 프로그래머스 "가장 큰 사각형 찾기" (0) | 2022.04.12 |
---|---|
(c++) 프로그래머스 "[1차] 캐시" (0) | 2022.04.12 |
(c++) 프로그래머스 "삼각 달팽이" (0) | 2022.04.12 |
(c++) 프로그래머스 "영어 끝말잇기" (0) | 2022.04.10 |
(c++) 프로그래머스 "예상 대진표" (0) | 2022.04.10 |