Skip to content

Commit 7c9c36e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f933a55 commit 7c9c36e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: backtracking/match_word_pattern.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def match_word_pattern(pattern :str, input_string: str) -> bool:
1+
def match_word_pattern(pattern: str, input_string: str) -> bool:
22
"""
33
Determine if a given pattern matches a string using backtracking.
44
@@ -15,6 +15,7 @@ def match_word_pattern(pattern :str, input_string: str) -> bool:
1515
>>> match_word_pattern("GG", "PythonJavaPython")
1616
False
1717
"""
18+
1819
def backtrack(pattern_index, str_index):
1920
if pattern_index == len(pattern) and str_index == len(input_string):
2021
return True
@@ -38,10 +39,13 @@ def backtrack(pattern_index, str_index):
3839
del pattern_map[char]
3940
del str_map[substr]
4041
return False
42+
4143
pattern_map = {}
4244
str_map = {}
4345
return backtrack(0, 0)
4446

47+
4548
if __name__ == "__main__":
4649
import doctest
50+
4751
doctest.testmod()

0 commit comments

Comments
 (0)