naive search
Fri Oct 28 2022 09:09:24 GMT+0000 (Coordinated Universal Time)
Saved by
@RedJohn
const 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]) break;
if(j === short.length - 1) count++
}
}
return count
}
naiveSearch("lorie loled ksjdklol lol djksjdloldsjd", "lol")
content_copyCOPY
Comments