11022

This is a dp problem where kmp algorithm(specially prefix function)  is used to solve the problem.

If a string is multiple of a repeated string then the difference between the string length and last index of the prefix table indicates the minimal length of the repeated string. A brief and nice discussion is available here .

 

Leave a Reply

Your email address will not be published. Required fields are marked *