Find the smallest period of input string in O(n)?
问题 Given the following problem : Definition : Let S be a string over alphabet Σ . S' is the smallest period of S if S' is the smallest string such that : S = (S')^k (S'') , where S'' is a prefix of S . If no such S' exists , then S is not periodic . Example : S = abcabcabcabca . Then abcabc is a period since S = abcabc abcabc a , but the smallest period is abc since S = abc abc abc abc a . Give an algorithm to find the smallest period of input string S or declare that S is not periodic. Hint :