Skip to content

Commit b110e34

Browse files
authored
Update string-matching-in-an-array.py
1 parent ccd8570 commit b110e34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/string-matching-in-an-array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def getPrefix(pattern):
105105
prefix[i] = j
106106
return prefix
107107

108-
def kmp(text, prefix):
108+
def kmp(text, pattern, prefix):
109109
j = -1
110110
for i in xrange(len(text)):
111111
while j != -1 and pattern[j+1] != text[i]:
@@ -120,7 +120,7 @@ def kmp(text, prefix):
120120
for i, pattern in enumerate(words):
121121
prefix = getPrefix(pattern)
122122
for j, text in enumerate(words):
123-
if i != j and kmp(text, prefix) != -1:
123+
if i != j and kmp(text, pattern, prefix) != -1:
124124
result.append(pattern)
125125
break
126126
return result

0 commit comments

Comments
 (0)