public class Solution {
public bool RepeatedSubstringPattern(string s) {
var len = s.Length;
if (len < )
{
return false;
}
else if (len == )
{
if (s[] == s[])
{
return true;
}
else
{
return false;
}
}
else
{
var bound = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(len) / )); for (int i = ; i <= bound; i++)
{
if (len % i == )
{
var teams = len / i;//共teams组,每组i个字符
var orginal = s.Substring(, i);//第一组的串
var count = ;
for (int t = ; t < teams; t++)
{
var copy = s.Substring(t * i, i);
if (orginal == copy)
{
count++;
}
else
{
break;
}
}
if (count == teams - )
{
return true;
}
}
}
return false;
}
}
}

https://leetcode.com/problems/repeated-substring-pattern/#/description

05-07 15:35