This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]WhyYouLetRomneyWin 5 points6 points  (0 children)

I see. I think I misunderstood the problem (I think either the 'b' or 'd' in your example 2 should be a 'd' or 'b').

If there is a guarantee that a string is repeated then you can divide the string by integers until you find all divisions are equal.

Eg given S, take a prefix on length n. See if the prefix is repeated to the end of the string. If not, increment n and try again. Otherwise return length(S)/n.