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. 【Quartz】Quartz将Job保存在数据库中所需表的说明

    QRTZ_CALENDARS 以 Blob 类型存储 Quartz 的 Calendar 信息 QRTZ_CRON_TRIGGERS 存储 Cron Trigger,包括 Cron表达式和时区信息  ...

  2. WPF控件NumericUpDown (转)

    WPF控件NumericUpDown示例 (转载请注明出处) 工具:Expression Blend 2 + Visual Studio 2008 语言:C# 框架:.Net Framework 3. ...

  3. map和jsonObject 这2中数据结构之间转换

    前台写json直接是:var array = [ ] ; 调用方法:array[index],若是对象,再[“key”] var obj = {''a'':123 , "b":&q ...

  4. Cygwin安装与使用入门

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/canlets/article/details/28646115 对于 UNIX 本身,也有各种称呼. ...

  5. Oracle更换字符集

    现有数据库使用字符集是GBK,做读写分离的时候,发现读库的数据库安装错误,使用了UTF8的字符集 需要把读库的字符集进行调整. 1.进入PLSQL查看下数据库字符集 select * from nls ...

  6. Digester库使用总结

    1.Digester是Apache软件基金会的Jakarta项目下的子Commons项目下的一个开源项目,Digester API包含3个包:org.apache.commons.digester,提 ...

  7. POJ3666序列最小差值

    题目:http://poj.org/problem?id=3666 dp方程可以是 d [ i ] [ j ] = min ( d [ i - 1 ] [ k ] ) + abs ( a [ i ] ...

  8. 专访TK教主于旸:原来那些搞安全的说的都是真的(图灵访谈)

    引用:http://www.ituring.com.cn/article/196609 于旸,网名“tombkeeper”,在国内黑客界被尊称为“TK教主”,现任腾讯玄武实验室总监.于旸从事信息安全研 ...

  9. bisect维持已排序的序列

    如下: import bisect # 用来处理已排序的序列,用来维持已排序的序列,升序 # 基于二分查找 li = [] bisect.insort(li, 2) bisect.insort(li, ...

  10. 淘宝用户api 如何获得App Key和API Secret

    下面我们通过截图的方式详细说明申请淘宝应用的步骤. 一.访问淘宝开放平台http://open.taobao.com/ 申请成为合作伙伴 二.填写个人信息申请入住 三.点击创建应用 四.填写应用名称, ...