当前位置:网站首页>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
边栏推荐
- pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
- JVM GC垃圾回收简述
- 数据孤岛是企业数字化转型遇到的第一道险关
- 注解。。。
- CSDN syntax description
- 国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
- Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
- [confluence] JVM memory adjustment
- 银行理财产品怎么买?需要办银行卡吗?
- Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
猜你喜欢
mock.js从对象数组中任选数据返回一个数组
使用高斯Redis实现二级索引
The project manager's "eight interview questions" is equal to a meeting
华南X99平台打鸡血教程
小试牛刀之NunJucks模板引擎
ASP. Net kindergarten chain management system source code
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
位运算介绍
PMP每日一练 | 考试不迷路-7.7
干货分享|DevExpress v22.1原版帮助文档下载集合
随机推荐
Data island is the first danger encountered by enterprises in their digital transformation
Cloud 组件发展升级
使用高斯Redis实现二级索引
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
CUDA versions are inconsistent, and errors are reported when compiling apex
[RT thread env tool installation]
How to buy stocks on your mobile phone and open an account? Is it safe to open an account
IP 工具类
ASP.NET幼儿园连锁管理系统源码
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
Time tools
Welcome to the markdown editor
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Make this crmeb single merchant wechat mall system popular, so easy to use!
841. String hash
A pot of stew, a collection of common commands of NPM and yarn cnpm
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
How to cooperate among multiple threads
[confluence] JVM memory adjustment
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim