mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Add type hints for "strings" folder (#2882)
* Add type hints for strings/ folder * Rerun other checks * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
def kmp(pattern, text):
|
||||
from typing import List
|
||||
|
||||
|
||||
def kmp(pattern: str, text: str) -> bool:
|
||||
"""
|
||||
The Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text
|
||||
with complexity O(n + m)
|
||||
@ -33,7 +36,7 @@ def kmp(pattern, text):
|
||||
return False
|
||||
|
||||
|
||||
def get_failure_array(pattern):
|
||||
def get_failure_array(pattern: str) -> List[int]:
|
||||
"""
|
||||
Calculates the new index we should go to if we fail a comparison
|
||||
:param pattern:
|
||||
|
Reference in New Issue
Block a user