Skip to content

Commit 70c3869

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

divide_and_conquer/suffix_array_lcp.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
34
def build_suffix_array(s: str) -> list[int]:
45
"""
56
Build the suffix array for the given string.
@@ -16,6 +17,7 @@ def build_suffix_array(s: str) -> list[int]:
1617
suffix_array = [suffix[1] for suffix in suffixes]
1718
return suffix_array
1819

20+
1921
def build_lcp_array(s: str, suffix_array: list[int]) -> list[int]:
2022
"""
2123
Build the LCP array for the given string and suffix array.
@@ -47,6 +49,7 @@ def build_lcp_array(s: str, suffix_array: list[int]) -> list[int]:
4749
h -= 1 # Decrease h for the next suffix
4850
return lcp
4951

52+
5053
# Example usage
5154
if __name__ == "__main__":
5255
s = "banana"
@@ -59,4 +62,6 @@ def build_lcp_array(s: str, suffix_array: list[int]) -> list[int]:
5962

6063
print("\nLCP Array:")
6164
for i in range(1, len(lcp_array)):
62-
print(f"LCP between {s[suffix_array[i - 1]:]} and {s[suffix_array[i]]}: {lcp_array[i]}")
65+
print(
66+
f"LCP between {s[suffix_array[i - 1]:]} and {s[suffix_array[i]]}: {lcp_array[i]}"
67+
)

0 commit comments

Comments
 (0)