▁than ▁non - constant - time ▁solutions . ▁▁▁▁ ▁""" ▁▁▁▁ ▁if ▁len ( S ) ▁== ▁ 0 : ▁▁▁▁▁▁▁▁ ▁return ▁[ [] ▁for ▁a ▁in ▁range ( AL PH AB ET _ SIZE )] ▁▁▁▁ ▁R ▁= ▁[[ - 1 ] ▁for ▁a ▁in ▁range ( AL PH AB ET _ SIZE )] ▁▁▁▁ ▁alpha ▁= ▁[- 1 ▁for ▁a ▁in ▁range ( AL PH AB ET _ SIZE )] ▁▁▁▁ ▁for ▁i , ▁c ▁in ▁enumerate ( S ): ▁▁▁▁▁▁▁▁ ▁alpha [ al phabet _ index ( c )] ▁= ▁i ▁▁▁▁▁▁▁▁ ▁for ▁j , ▁a ▁in ▁enumerate ( alpha ): ▁▁▁▁▁▁▁▁▁▁▁▁ ▁R [ j ]. append ( a ) ▁▁▁▁ ▁return ▁R ▁ ▁def ▁good _ su ff ix _ table ( S : ▁str ) ▁-> ▁List [ int ]: ▁▁▁▁ ▁""" ▁▁▁▁ ▁Gener ates ▁L ▁for ▁S , ▁an ▁array ▁used ▁in ▁the ▁implementation ▁of ▁the ▁strong ▁good ▁suffix ▁rule . ▁▁▁▁ ▁L [ i ] ▁= ▁k , ▁the ▁largest ▁position ▁in ▁S ▁such ▁that ▁S [ i :] ▁( the ▁suffix ▁of ▁S ▁starting ▁at ▁i ) ▁matches ▁▁▁▁ ▁a ▁suffix ▁of ▁S [: k ] ▁( a ▁substring ▁in ▁S ▁ending ▁at ▁k ). ▁U sed ▁in ▁Bo yer - Mo ore , ▁L ▁gives ▁an ▁amount ▁to ▁▁▁▁ ▁shift ▁P ▁relative ▁to ▁T ▁such ▁that ▁no ▁instances ▁of ▁P ▁in ▁T ▁are ▁ski pped ▁and ▁a ▁suffix ▁of ▁P [: L [ i ]] ▁▁▁▁ ▁matches ▁the ▁substring ▁of ▁T ▁matched ▁by ▁a