mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-07 10:00:55 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
123e6f0c33
commit
848a358d80
|
@ -22,7 +22,9 @@ class SuffixArray:
|
|||
"""
|
||||
n = len(self.text)
|
||||
# Create a list of suffix indices sorted by the suffixes they point to
|
||||
sorted_suffix_indices = sorted(range(n), key=lambda suffix_index: self.text[suffix_index:])
|
||||
sorted_suffix_indices = sorted(
|
||||
range(n), key=lambda suffix_index: self.text[suffix_index:]
|
||||
)
|
||||
return sorted_suffix_indices
|
||||
|
||||
def build_lcp_array(self) -> List[int]:
|
||||
|
@ -49,7 +51,9 @@ class SuffixArray:
|
|||
for i in range(n):
|
||||
if rank[i] > 0:
|
||||
j = suffix_array[rank[i] - 1] # Previous suffix in the sorted order
|
||||
while (i + h < n) and (j + h < n) and self.text[i + h] == self.text[j + h]:
|
||||
while (
|
||||
(i + h < n) and (j + h < n) and self.text[i + h] == self.text[j + h]
|
||||
):
|
||||
h += 1
|
||||
lcp[rank[i]] = h
|
||||
if h > 0:
|
||||
|
@ -77,7 +81,6 @@ class SuffixArray:
|
|||
print(f"{suffix_index}: {self.text[suffix_index:]}")
|
||||
|
||||
|
||||
|
||||
# Example usage:
|
||||
if __name__ == "__main__":
|
||||
text = "banana"
|
||||
|
|
Loading…
Reference in New Issue
Block a user