mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
[mypy] Fix type annotations for strings/naive_string_search.py (#4611)
This commit is contained in:
parent
cd987372e4
commit
3c225247b8
|
@ -1,10 +1,8 @@
|
||||||
"""
|
"""
|
||||||
https://en.wikipedia.org/wiki/String-searching_algorithm#Na%C3%AFve_string_search
|
https://en.wikipedia.org/wiki/String-searching_algorithm#Na%C3%AFve_string_search
|
||||||
|
|
||||||
this algorithm tries to find the pattern from every position of
|
this algorithm tries to find the pattern from every position of
|
||||||
the mainString if pattern is found from position i it add it to
|
the mainString if pattern is found from position i it add it to
|
||||||
the answer and does the same for position i+1
|
the answer and does the same for position i+1
|
||||||
|
|
||||||
Complexity : O(n*m)
|
Complexity : O(n*m)
|
||||||
n=length of main string
|
n=length of main string
|
||||||
m=length of pattern string
|
m=length of pattern string
|
||||||
|
@ -39,4 +37,4 @@ def naive_pattern_search(s: str, pattern: str) -> list:
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
assert naive_pattern_search("ABCDEFG", "DE") == [3]
|
assert naive_pattern_search("ABCDEFG", "DE") == [3]
|
||||||
print(f"{naive_pattern_search('ABAAABCDBBABCDDEBCABC', 'ABC') = }")
|
print(naive_pattern_search("ABAAABCDBBABCDDEBCABC", "ABC"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user