Skip to content

Commit 848a358

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 123e6f0 commit 848a358

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

divide_and_conquer/Suffix Array and LCP implementation.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def build_suffix_array(self) -> List[int]:
2222
"""
2323
n = len(self.text)
2424
# Create a list of suffix indices sorted by the suffixes they point to
25-
sorted_suffix_indices = sorted(range(n), key=lambda suffix_index: self.text[suffix_index:])
25+
sorted_suffix_indices = sorted(
26+
range(n), key=lambda suffix_index: self.text[suffix_index:]
27+
)
2628
return sorted_suffix_indices
2729

2830
def build_lcp_array(self) -> List[int]:
@@ -49,7 +51,9 @@ def build_lcp_array(self) -> List[int]:
4951
for i in range(n):
5052
if rank[i] > 0:
5153
j = suffix_array[rank[i] - 1] # Previous suffix in the sorted order
52-
while (i + h < n) and (j + h < n) and self.text[i + h] == self.text[j + h]:
54+
while (
55+
(i + h < n) and (j + h < n) and self.text[i + h] == self.text[j + h]
56+
):
5357
h += 1
5458
lcp[rank[i]] = h
5559
if h > 0:
@@ -77,7 +81,6 @@ def display(self) -> None:
7781
print(f"{suffix_index}: {self.text[suffix_index:]}")
7882

7983

80-
8184
# Example usage:
8285
if __name__ == "__main__":
8386
text = "banana"

0 commit comments

Comments
 (0)