File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ def build_suffix_array(self) -> List[int]:
22
22
"""
23
23
n = len (self .text )
24
24
# 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
+ )
26
28
return sorted_suffix_indices
27
29
28
30
def build_lcp_array (self ) -> List [int ]:
@@ -49,7 +51,9 @@ def build_lcp_array(self) -> List[int]:
49
51
for i in range (n ):
50
52
if rank [i ] > 0 :
51
53
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
+ ):
53
57
h += 1
54
58
lcp [rank [i ]] = h
55
59
if h > 0 :
@@ -77,7 +81,6 @@ def display(self) -> None:
77
81
print (f"{ suffix_index } : { self .text [suffix_index :]} " )
78
82
79
83
80
-
81
84
# Example usage:
82
85
if __name__ == "__main__" :
83
86
text = "banana"
You can’t perform that action at this time.
0 commit comments