algorithm - How to detect palindrome cycle length in a string? -


suppose string "abaabaabaabaaba", palindrome cycle here 3, because can find string aba @ every 3rd position , can augment palindrome concatenating number of "aba"s string.

i think it's possible detect efficiently using manacher's algorithm how?

you can find searching string s in s+s. first index find cycle number want (may entire string). in python like:

in [1]: s = "abaabaabaabaaba"  in [2]: print (s+s).index(s, 1) 3 

the 1 there ignore index 0, trivial match.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -