There was an error while loading. Please reload this page.
1 parent f5988cc commit bb57a9dCopy full SHA for bb57a9d
1 file changed
strings/boyer_moore_search.py
@@ -86,15 +86,15 @@ def bad_character_heuristic(self) -> list[int]:
86
"""
87
88
positions = []
89
- for i in range(self.textLen - self.patLen + 1):
+ i = 0
90
+ while i <= self.textLen - self.patLen:
91
mismatch_index = self.mismatch_in_text(i)
92
if mismatch_index == -1:
93
positions.append(i)
94
+ i += 1
95
else:
96
match_index = self.match_in_pattern(self.text[mismatch_index])
- i = (
- mismatch_index - match_index
97
- ) # shifting index lgtm [py/multiple-definition]
+ i = max(i + 1, mismatch_index - match_index)
98
return positions
99
100
0 commit comments