当前位置:网站首页>力扣 459. 重复的子字符串
力扣 459. 重复的子字符串
2022-07-07 17:53:00 【Tomorrowave】
459. 重复的子字符串
给定一个非空的字符串 s ,检查是否可以通过由它的一个子串重复多次构成。
示例 1:
输入: s = “abab”
输出: true
解释: 可由子串 “ab” 重复两次构成。
思路:
首先构造一个让任意长度的字符串去匹配另一个字符串,遍历抽取字串,符合不符合条件,荣获在主函数里面遍历一遍母串
代码部分
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
边栏推荐
- Make insurance more "safe"! Kirin Xin'an one cloud multi-core cloud desktop won the bid of China Life Insurance, helping the innovation and development of financial and insurance information technolog
- Kirin Xin'an cloud platform is newly upgraded!
- Solve the problem of remote rviz error reporting
- 2022年投资哪个理财产品收益高?
- 关于自身的一些安排
- 开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
- 强化学习-学习笔记8 | Q-learning
- mock.js从对象数组中任选数据返回一个数组
- R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
- 【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
猜你喜欢
Netease Yunxin participated in the preparation of the standard "real time audio and video service (RTC) basic capability requirements and evaluation methods" issued by the Chinese Academy of Communica
8 CAS
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
Sword finger offer II 013 Sum of two-dimensional submatrix
多个线程之间如何协同
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry
openEuler 资源利用率提升之道 01:概论
Flink并行度和Slot详解
Detailed explanation of Flink parallelism and slot
Cloud 组件发展升级
随机推荐
what‘s the meaning of inference
谷歌seo外链Backlinks研究工具推荐
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Kubernetes——kubectl命令行工具用法详解
[RT thread env tool installation]
Solve the problem of remote rviz error reporting
Some arrangements about oneself
ASP. Net kindergarten chain management system source code
Compiler optimization (4): inductive variables
ASP. Net gymnasium integrated member management system source code, free sharing
【STL】vector
Jürgen Schmidhuber回顾LSTM论文等发表25周年:Long Short-Term Memory. All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversarial RL. Soccer learn
Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
JVM 类加载机制
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
Throughput
IP 工具类
Boot 和 Cloud 的版本选型