当前位置:网站首页>Force buckle 459 Duplicate substring
Force buckle 459 Duplicate substring
2022-07-07 20:06:00 【Tomorrowave】
459. Repeated substrings
Given a non empty string s , Check whether it can be formed by repeating one of its substrings multiple times .
Example 1:
Input : s = “abab”
Output : true
explain : But by substring “ab” Repeat twice to form .
Ideas :
First, construct a string of arbitrary length to match another string , Traversal extraction string , Meet or not meet the conditions , You can traverse the parent string in the main function
Code section
class Solution:
def isPrefixMultiple(self,s:str,lengh):
cnt=len(s)//lengh
for i in range(cnt):
for j in range(lengh):
if s[i*lengh+j]!=s[j]:
return False
return True
def repeatedSubstringPattern(self, s: str) -> bool:
nn=len(s)
for i in range(1,nn):
if nn%i==0:
if self.isPrefixMultiple(s,i):
return True
return False
边栏推荐
- Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
- mysql 的一些重要知识
- 831. KMP字符串
- Browse the purpose of point setting
- R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置position参数配置不同分组数据点的分离程度
- Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
- J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar
- Sword finger offer II 013 Sum of two-dimensional submatrix
- 剑指 Offer II 013. 二维子矩阵的和
- 吞吐量Throughout
猜你喜欢
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
ASP.NET学习& asp‘s one word
mysql 的一些重要知识
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Sword finger offer II 013 Sum of two-dimensional submatrix
The project manager's "eight interview questions" is equal to a meeting
【STL】vector
vulnhub之Funfox2
随机推荐
Implement secondary index with Gaussian redis
pom.xml 配置文件标签作用简述
R language ggplot2 visualization: use the ggstripchart function of ggpubr package to visualize the dot strip plot, set the position parameter, and configure the separation degree of different grouped
Chapter 20 using work queue manager (3)
R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
Tp6 realize Commission ranking
R语言ggplot2可视化:使用ggpubr包的ggqqplot函数可视化QQ图(Quantile-Quantile plot)
Boot 和 Cloud 的版本选型
Semantic SLAM源码解析
831. KMP string
pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
MRS离线数据分析:通过Flink作业处理OBS数据
ASP. Net learning & ASP's one word
JVM class loading mechanism
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
开源OA开发平台:合同管理使用手册
毕业季|遗憾而又幸运的毕业季
[confluence] JVM memory adjustment
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
841. String hash