I take a input from the user and its a string with a certain substring which repeats itself all through the string. I need to output the substring or its length AKA period.
You can do this in linear time and constant additional space by inductively computing the period of each prefix of the string. I can't recall the details (there are several things to get right), but you can find them in Section 13.6 of "Text algorithms" by Crochemore and Rytter under function Per(x).