We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cb57da0 commit 4d6e154Copy full SHA for 4d6e154
algorithms/searching/kmp_search.py
@@ -29,15 +29,15 @@ def search(string, word):
29
return offsets
30
31
prefix = compute_prefix(word)
32
- q = 0 # q is the number of characters matched
+ q = 0
33
for index, letter in enumerate(string):
34
while q > 0 and word[q] != letter:
35
- q = prefix[q - 1] # next character does not match
+ q = prefix[q - 1]
36
if word[q] == letter:
37
q += 1
38
if q == word_length:
39
offsets.append(index - word_length + 1)
40
- q = prefix[q - 1] # look for next match
41
42
43
0 commit comments