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. (转)typedef和define的详细区别

    来源:http://developer.51cto.com/art/201104/256060.htm typedef是一种在计算机编程语言中用来声明自定义数据类型,配合各种原有数据类型来达到简化编程 ...

  2. LG1955 [NOI2015]程序自动分析

    题意 题目描述 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3...代表程序中出现的变量,给定n个形如xi=xj或xi≠x ...

  3. LG2521 [HAOI2011]防线修建

    题意 题目描述 近来A国和B国的矛盾激化,为了预防不测,A国准备修建一条长长的防线,当然修建防线的话,肯定要把需要保护的城市修在防线内部了.可是A国上层现在还犹豫不决,到底该把哪些城市作为保护对象呢? ...

  4. 使用cglib动态创建javabean

    动态创建javabean对于我们进行开发,会有一定的帮助,一下是使用cglib动态创建javabean的一个例子: 先贴上code: package com.dalong.CreateCode; im ...

  5. Linux高级文本处理命令

    cut 一.cut命令 功能:cut命令可以从一个文本文件/文本流中提取文本列 语法: cut -d '分割字符' -f fields ##用于有特定分割字符 cut -c 字符区间 ##用于排列整齐 ...

  6. spring cloud 知识点

    优秀的介绍资料: 资料 地址 spring cloud 中文网 https://springcloud.cc/ spring cloud 介绍 https://www.jianshu.com/p/74 ...

  7. Linq to sql 增删改查(转帖)

    http://blog.csdn.net/pan_junbiao/article/details/7015633   (LINQ To SQL 语法及实例大全) 代码 Code highlightin ...

  8. ASM配置管理

    http://blog.chinaunix.net/uid-22646981-id-3060280.htmlhttp://blog.sina.com.cn/s/blog_6a5aa0300102uys ...

  9. NSWindow添加NSViewController

    大概这样,笔记一下,防止忘记 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { MyViewControl ...

  10. 【Spring学习笔记-3.1】让bean获取spring容器上下文(applicationContext.xml)

    *.hl_mark_KMSmartTagPinkImg{background-color:#ffaaff;}*.hl_mark_KMSmartTagBlueImg{background-color:# ...