Let's define y^i be the copy of the string y with itself i times. For example (ab)^3=ababab. We define thee amount of times we copied a string in x to be r if x=y^r for some string y when r is the maximum number with this characteristic. (so y is the minimal).
Please help me find an algorithm which gets a string P[1…n] and computes for each prefix p_i=p[1…i] its r.
I believe it should be something with KMP table. I compute it for "ababab" and got {0 0 1 2 3 4} but I couldn't find any pattern or came with any smart conclusion.
Thanks a lot!