1- import copy
21import functools
32import typing
43
@@ -11,7 +10,7 @@ def _sa_naive(s: typing.List[int]) -> typing.List[int]:
1110def _sa_doubling (s : typing .List [int ]) -> typing .List [int ]:
1211 n = len (s )
1312 sa = list (range (n ))
14- rnk = copy . deepcopy ( s )
13+ rnk = s . copy ( )
1514 tmp = [0 ] * n
1615 k = 1
1716 while k < n :
@@ -75,14 +74,14 @@ def induce(lms: typing.List[int]) -> None:
7574 nonlocal sa
7675 sa = [- 1 ] * n
7776
78- buf = copy . deepcopy ( sum_s )
77+ buf = sum_s . copy ( )
7978 for d in lms :
8079 if d == n :
8180 continue
8281 sa [buf [s [d ]]] = d
8382 buf [s [d ]] += 1
8483
85- buf = copy . deepcopy ( sum_l )
84+ buf = sum_l . copy ( )
8685 sa [buf [s [n - 1 ]]] = n - 1
8786 buf [s [n - 1 ]] += 1
8887 for i in range (n ):
@@ -91,7 +90,7 @@ def induce(lms: typing.List[int]) -> None:
9190 sa [buf [s [v - 1 ]]] = v - 1
9291 buf [s [v - 1 ]] += 1
9392
94- buf = copy . deepcopy ( sum_l )
93+ buf = sum_l . copy ( )
9594 for i in range (n - 1 , - 1 , - 1 ):
9695 v = sa [i ]
9796 if v >= 1 and ls [v - 1 ]:
@@ -160,7 +159,6 @@ def suffix_array(s: typing.Union[str, typing.List[int]],
160159 upper : typing .Optional [int ] = None ) -> typing .List [int ]:
161160 '''
162161 SA-IS, linear-time suffix array construction
163-
164162 Reference:
165163 G. Nong, S. Zhang, and W. H. Chan,
166164 Two Efficient Algorithms for Linear Time Suffix Array Construction
@@ -195,7 +193,6 @@ def lcp_array(s: typing.Union[str, typing.List[int]],
195193 sa : typing .List [int ]) -> typing .List [int ]:
196194 '''
197195 Longest-Common-Prefix computation
198-
199196 Reference:
200197 T. Kasai, G. Lee, H. Arimura, S. Arikawa, and K. Park,
201198 Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its
@@ -232,7 +229,6 @@ def lcp_array(s: typing.Union[str, typing.List[int]],
232229def z_algorithm (s : typing .Union [str , typing .List [int ]]) -> typing .List [int ]:
233230 '''
234231 Z algorithm
235-
236232 Reference:
237233 D. Gusfield,
238234 Algorithms on Strings, Trees, and Sequences: Computer Science and
0 commit comments