@@ -31,13 +31,6 @@ def cmp(x: int, y: int) -> int:
3131
3232
3333def _sa_is (s : typing .List [int ], upper : int ) -> typing .List [int ]:
34- '''
35- SA-IS, linear-time suffix array construction
36- Reference:
37- G. Nong, S. Zhang, and W. H. Chan,
38- Two Efficient Algorithms for Linear Time Suffix Array Construction
39- '''
40-
4134 threshold_naive = 10
4235 threshold_doubling = 40
4336
@@ -165,6 +158,14 @@ def induce(lms: typing.List[int]) -> None:
165158
166159def suffix_array (s : typing .Union [str , typing .List [int ]],
167160 upper : typing .Optional [int ] = None ) -> typing .List [int ]:
161+ '''
162+ SA-IS, linear-time suffix array construction
163+
164+ Reference:
165+ G. Nong, S. Zhang, and W. H. Chan,
166+ Two Efficient Algorithms for Linear Time Suffix Array Construction
167+ '''
168+
168169 if isinstance (s , str ):
169170 return _sa_is ([ord (c ) for c in s ], 255 )
170171 elif upper is None :
@@ -193,6 +194,8 @@ def cmp(left: int, right: int) -> int:
193194def lcp_array (s : typing .Union [str , typing .List [int ]],
194195 sa : typing .List [int ]) -> typing .List [int ]:
195196 '''
197+ Longest-Common-Prefix computation
198+
196199 Reference:
197200 T. Kasai, G. Lee, H. Arimura, S. Arikawa, and K. Park,
198201 Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its
@@ -228,6 +231,8 @@ def lcp_array(s: typing.Union[str, typing.List[int]],
228231
229232def z_algorithm (s : typing .Union [str , typing .List [int ]]) -> typing .List [int ]:
230233 '''
234+ Z algorithm
235+
231236 Reference:
232237 D. Gusfield,
233238 Algorithms on Strings, Trees, and Sequences: Computer Science and
0 commit comments