Created
May 20, 2019 10:41
-
-
Save Ikhan/da09c713c2a31db367a96305f40d1a56 to your computer and use it in GitHub Desktop.
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 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