Skip to content

Instantly share code, notes, and snippets.

@Ikhan
Created May 20, 2019 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ikhan/da09c713c2a31db367a96305f40d1a56 to your computer and use it in GitHub Desktop.
Save Ikhan/da09c713c2a31db367a96305f40d1a56 to your computer and use it in GitHub Desktop.
function naiveSearch(long, short) {
let count = 0;
for (let i = 0; i<long.length; i++) {
for(let j=0; j<short.length; j++) {
if (short[j] !== long[i+j]) {
console.log('break');
break;
}
if (j === short.length -1) {
count++;
}
}
}
return count;
}
naiveSearch("lorie loled", "lol")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment