Skip to content

Commit fca604c

Browse files
committed
Fixes
1 parent 3929a02 commit fca604c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pydatastructs/strings/algorithms.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,19 @@ def bitap_search(text, pattern):
9090
Returns the starting index of the pattern in the text, or -1 if not found.
9191
"""
9292
m = len(pattern)
93-
R = ~1 # Bit array for tracking matches
93+
R = ~1
9494
pattern_mask = {}
9595

96-
# Preprocess the pattern into a bitmask
9796
for i in range(m):
9897
pattern_mask[pattern[i]] = pattern_mask.get(pattern[i], ~0) & ~(1 << i)
9998

10099
for i in range(len(text)):
101100
R |= pattern_mask.get(text[i], ~0)
102101
R <<= 1
103102
if (R & (1 << m)) == 0:
104-
return i - m + 1 # Match found
103+
return i - m + 1
105104

106-
return -1 # No match found
105+
return -1
107106

108107
def _knuth_morris_pratt(text, query):
109108
if len(text) == 0 or len(query) == 0:

0 commit comments

Comments
 (0)