[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-10-02 05:20:39 +00:00
parent 23a99c859d
commit 6fb609b07d

View File

@ -1,5 +1,6 @@
# https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
def knuth_morris_pratt(text: str, pattern: str) -> list[int]:
"""
Knuth-Morris-Pratt (KMP) string search algorithm in Python.
@ -19,6 +20,7 @@ def knuth_morris_pratt(text: str, pattern: str) -> list[int]:
[]
"""
def build_prefix_table(pattern: str) -> list[int]:
"""
Build the prefix table for the given pattern.
@ -60,6 +62,7 @@ def knuth_morris_pratt(text: str, pattern: str) -> list[int]:
j = prefix_table[j - 1]
return positions
if __name__ == "__main__":
text = input("Enter the text: ")
pattern = input("Enter the pattern to search for: ")