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

leetcode459的更多相关文章

  1. [Swift]LeetCode459. 重复的子字符串 | Repeated Substring Pattern

    Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ...

  2. LeetCode459. Repeated Substring Pattern

    Description Given a non-empty string check if it can be constructed by taking a substring of it and ...

  3. Leetcode459.Repeated Substring Pattern重复的子字符串

    给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且长度不超过10000. 示例 1: 输入: "abab" 输出: True 解释 ...

  4. LeetCode 459. 重复的子字符串(Repeated Substring Pattern)

    459. 重复的子字符串 459. Repeated Substring Pattern 题目描述 给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且 ...

随机推荐

  1. 《DSP using MATLAB》Problem 4.16

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  2. 字符串匹配--扩展KMP模板

    对于一个字符串 s 以及子串 t ,扩展KMP可以用来求 t 与 s 的每个子串的最长公共前缀 ext [ i ],当然,如果有某个 ext 值等于 t 串的长度 lent ,那么就说明从其对应的 i ...

  3. Linux elasticsearch 安装 遇到的问题

    备注:我的 Linux 测试机  是2G 内存的 ,估计内存小于 我的内存肯定会出这个问题 .(安装的最新版6.3.2) 1.  下载文件  解压 2 .试着 运行 bin 下面的 elasticse ...

  4. Netflix 是怎样的一家公司?为什么它在美国非常成功

    https://www.zhihu.com/question/19552101 作者:陈达链接:https://www.zhihu.com/question/19552101/answer/11486 ...

  5. javascript的循环使用

    学习网址: http://www.w3school.com.cn/js/js_loop_for.asp JavaScript 循环 如果您希望一遍又一遍地运行相同的代码,并且每次的值都不同,那么使用循 ...

  6. [boost] : test库

    最小化的测试套件minimal_test test库提供一个最小化的测试套件minimal_test, 类似lightweight_test适合入门级测试. 需要包含文件文#include <b ...

  7. 实例直观解释sessionid的作用

    有两个php页面,demo1.php与demo2.php.如果想要在demo1.php创建一个session需要在的demo2.php或者说其它页面都可以获取到设置的session的值,达到会话的功能 ...

  8. linux 标准I/O (二)

    <Uinx 环境高级编程笔记>   以前经常遇到两种I/O操作 一类是f打头的fopen, fread, fwrite 一类是没有f打头的open, read, fwrite 原来一个是U ...

  9. 新玩具,React v16.7.0-alpha Hooks

    周五看见React v16.7.0-alpha Hooks,今早起来看见圈里已经刷屏了Hooks,正好周末,正好IG和G2的比赛还没开始,研究下... 刚刚接触react时候非常喜欢用函数式组件,因为 ...

  10. xml dom minidom

    一. xml相关术语: 1.Document(文档): 对应一个xml文件 2.Declaration(声明): <?xml version="1.0" encoding=& ...