[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-10-19 07:53:45 +00:00
parent dae072c0c7
commit 70c3869f42

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
def build_suffix_array(s: str) -> list[int]:
"""
Build the suffix array for the given string.
@ -16,6 +17,7 @@ def build_suffix_array(s: str) -> list[int]:
suffix_array = [suffix[1] for suffix in suffixes]
return suffix_array
def build_lcp_array(s: str, suffix_array: list[int]) -> list[int]:
"""
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]:
h -= 1 # Decrease h for the next suffix
return lcp
# Example usage
if __name__ == "__main__":
s = "banana"
@ -59,4 +62,6 @@ if __name__ == "__main__":
print("\nLCP Array:")
for i in range(1, len(lcp_array)):
print(f"LCP between {s[suffix_array[i - 1]:]} and {s[suffix_array[i]]}: {lcp_array[i]}")
print(
f"LCP between {s[suffix_array[i - 1]:]} and {s[suffix_array[i]]}: {lcp_array[i]}"
)