leetcode459
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的更多相关文章
- [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 ...
- LeetCode459. Repeated Substring Pattern
Description Given a non-empty string check if it can be constructed by taking a substring of it and ...
- Leetcode459.Repeated Substring Pattern重复的子字符串
给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且长度不超过10000. 示例 1: 输入: "abab" 输出: True 解释 ...
- LeetCode 459. 重复的子字符串(Repeated Substring Pattern)
459. 重复的子字符串 459. Repeated Substring Pattern 题目描述 给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且 ...
随机推荐
- vulcanjs 简单package 编写
vulcanjs 功能是以包进行管理,包里面包含了运行依赖的组件以及对于路由的注册 参考项目 项目结构 ├── README.md ├── license.md ├── package-lock.js ...
- 在CentOS和RHEL中配置SNMPv3
首先,使用yum安装必要的软件 [root@server ~]# yum install net-snmp-utils net-snmp-devel安装完成之后, 先停止snmpd,再创建具有只读属性 ...
- Sqoop之 Sqoop 1.4.6 安装
1. sqoop数据迁移 1.1 概述 sqoop是apache旗下一款“Hadoop和关系数据库服务器之间传送数据”的工具. 导入数据:MySQL,Oracle导入数据到Hadoop的HDFS.HI ...
- docker 知识点
docker 教程:http://www.runoob.com/docker/docker-tutorial.html docker 仓库地址:https://store.docker.com/ do ...
- Spark的word count
word count package com.spark.app import org.apache.spark.{SparkContext, SparkConf} /** * Created by ...
- Mybatis常见面试题 二
1.mybatis是什么? (1)mybatis是一个优秀的基于java的持久层框架,它内部封装了jdbc,使开发者只需要关注sql语句本身,而不需要花费精力去处理加载驱动.创建连接.创建state ...
- sql distinct 去除重复的字段
居然已经有人写了 那我就直接复制其链接吧
- mysql 按照 where in 排序
select * from user_extend where `unique` in('mark.liu@xxxx.com','jason.gan@xxxx.com','ssgao@xxxx.com ...
- bzoj3157 3516 国王奇遇记
Description Input 共一行包括两个正整数N和M. Output 共一行为所求表达式的值对10^9+7取模的值. 特判m=1 m≠1时: 设S[u]=sigma(i^u*m^i) m*S ...
- 2018-2019 20165226 Exp5 MSF基础应用
2018-2019 20165226 Exp5 MSF基础应用 目录 一.实验内容说明及基础问题回答 二.实验过程 Task1 主动攻击实践 ms08_067 ms17_010 Task2 针对浏览器 ...