From 6fb609b07dd1bfd7e5ff156e5d88fefcda9f73ee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 05:20:39 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- searches/knuth_morris_pratt_algorithm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/searches/knuth_morris_pratt_algorithm.py b/searches/knuth_morris_pratt_algorithm.py index 1648821b1..8516e1840 100644 --- a/searches/knuth_morris_pratt_algorithm.py +++ b/searches/knuth_morris_pratt_algorithm.py @@ -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: ")