Created
August 21, 2020 17:44
-
-
Save yungyungGwon/cf39203afb47b1496bdf78fca6fb7be3 to your computer and use it in GitHub Desktop.
Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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