Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eba5286

Browse files
committedOct 19, 2024·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e746d93 commit eba5286

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎data_structures/persistent_segment_tree.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,3 @@ def _query(self, node, start, end, left, right):
148148
# Querying the updated version
149149
assert pst.query(new_version, 0, 4) == 22 # sum of [1, 2, 10, 4, 5]
150150
assert pst.query(0, 0, 4) == 15 # original version unchanged
151-

‎divide_and_conquer/suffix_array_lcp.py

Lines changed: 6 additions & 1 deletion
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)
Please sign in to comment.