首先就是求解S的最小周期,使用next数组,最后tmin = len - next[len]
如果len 能够被整除,那么说明是由若干个最小循环节重复构成,否则需要添加额外的字符
bool repeatedSubstringPattern(string s)
{
int n = s.size();
s = ' ' + s;
vector<int> next(n, -1);
for (int i = 2, j = 0; i < n; i++)
{
while (j && s[i] != s[j + 1])
j = next[j];
if (s[i] == s[j + 1])
j++;
next[i] = j;
}
int t = n - next[n]; // len - ne[len], len 表示字符长度
return t < n && n % t == 0;
}