当前位置:网站首页>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
边栏推荐
猜你喜欢

BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?

Welcome to the markdown editor
![[RT thread env tool installation]](/img/bc/9b39651d40a240f0893200793f67e9.png)
[RT thread env tool installation]

使用高斯Redis实现二级索引

LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字

ASP.NET幼儿园连锁管理系统源码

Interpretation of transpose convolution theory (input-output size analysis)

RESTAPI 版本控制策略【eolink 翻译】

Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記

论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
随机推荐
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
ASP.NET体育馆综合会员管理系统源码,免费分享
SQL common optimization
线性基
开源OA开发平台:合同管理使用手册
IP tools
ASP.NET学习& asp‘s one word
力扣 643. 子数组最大平均数 I
使用高斯Redis实现二级索引
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
Data island is the first danger encountered by enterprises in their digital transformation
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
【STL】vector
JVM GC垃圾回收简述
9 原子操作类之18罗汉增强
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
[auto.js] automatic script
一锅乱炖,npm、yarn cnpm常用命令合集
IP 工具类
Ways to improve the utilization of openeuler resources 01: Introduction