728x90
반응형
#include <string>
#include <vector>
using namespace std;
int solution(string skill, vector<string> skill_trees) {
int snum[ 26 ];
int answer = 0, flag = 0;
string s;
if(skill.size() == 1 ) return skill_trees.size();
for(int i = 0 ; i < skill_trees.size() ; i++){
s = skill_trees[i];
for(int j = 0 ; j < skill.size() ; j++){
if( s.find( skill[j] ) != string::npos )
snum[j] = s.find( skill[j] );
else snum[j] = skill.size()*2 + j;
}
flag = 0;
for(int j=1 ; j<skill.size() ; j++){
if(snum[j-1] > snum[j]) flag = 1;
}
if(flag != 1) answer++;
}
return answer;
}
https://programmers.co.kr/learn/courses/30/lessons/49993
728x90
반응형
'Problem Solving' 카테고리의 다른 글
1-6. Pascal's Triangle (LeetCode 118) (0) | 2021.07.07 |
---|---|
1-5. Plus One (LeetCode 66) (0) | 2021.07.07 |
1-4. 평균은 넘겠지 (백준 4344) (0) | 2021.07.07 |
1-3. Assign Cookies (LeetCode 455) (0) | 2021.07.07 |
1-1. 음계 판별하기 (백준 2920) (2) | 2021.07.07 |
댓글