diff --git a/src/algorithms/string/knuth-morris-pratt/knuthMorrisPratt.js b/src/algorithms/string/knuth-morris-pratt/knuthMorrisPratt.js index e4344b77..82b94904 100644 --- a/src/algorithms/string/knuth-morris-pratt/knuthMorrisPratt.js +++ b/src/algorithms/string/knuth-morris-pratt/knuthMorrisPratt.js @@ -43,14 +43,14 @@ export default function knuthMorrisPratt(text, word) { if (text[textIndex] === word[wordIndex]) { // We've found a match. if (wordIndex === word.length - 1) { - return (textIndex - word.length) + 1; + return textIndex - word.length + 1; } wordIndex += 1; textIndex += 1; } else if (wordIndex > 0) { wordIndex = patternTable[wordIndex - 1]; } else { - wordIndex = 0; + // wordIndex = 0; textIndex += 1; } }