Skip to content

Instantly share code, notes, and snippets.

@yungyungGwon
Created August 21, 2020 17:44
Show Gist options
  • Save yungyungGwon/cf39203afb47b1496bdf78fca6fb7be3 to your computer and use it in GitHub Desktop.
Save yungyungGwon/cf39203afb47b1496bdf78fca6fb7be3 to your computer and use it in GitHub Desktop.
Algorithm
function solution(skill, skill_trees){
var answer = 0;
var compare1 = "", compare2 = "";
for(var i = 0; i < skill_trees.length; i++){
var startIndex = 0;
var flag = true;
for(var j = 0; j < skill_trees[i].length; j++){
for(var idx = startIndex; idx < skill.length; idx++){
compare1 = skill.charAt(idx);
compare2 = skill_trees[i].charAt(j);
if(compare1 == compare2){
if(idx != startIndex){
flag = false;
}
else{
startIndex++;
break;
}
}
}
}
if(flag) answer++;
}
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment