当前位置:网站首页>力扣 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
边栏推荐
- 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
- 现在股票开户可以直接在网上开吗?安全吗。
- Flink并行度和Slot详解
- Interpretation of transpose convolution theory (input-output size analysis)
- 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
- JVM GC垃圾回收简述
- 华南X99平台打鸡血教程
- PMP每日一练 | 考试不迷路-7.7
- 2022如何评估与选择低代码开发平台?
- openEuler 资源利用率提升之道 01:概论
猜你喜欢

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

干货分享|DevExpress v22.1原版帮助文档下载集合

mock. JS returns an array from the optional data in the object array

转置卷积理论解释(输入输出大小分析)

9 原子操作类之18罗汉增强

Introduction to bit operation

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

openEuler 资源利用率提升之道 01:概论
![最多可以参加的会议数目[贪心 + 优先队列]](/img/f3/e8e939e0393efc404cc159d7d33364.png)
最多可以参加的会议数目[贪心 + 优先队列]

# 欢迎使用Markdown编辑器
随机推荐
【RT-Thread env 工具安装】
R language ggplot2 visualization: use the ggecdf function of ggpubr package to visualize the grouping experience cumulative density distribution function curve, and the linetype parameter to specify t
R语言dplyr包mutate_at函数和min_rank函数计算dataframe中指定数据列的排序序号值、名次值、将最大值的rank值赋值为1
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
项目经理『面试八问』,看了等于会了
Introduction to bit operation
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
Detailed explanation of Flink parallelism and slot
MySQL、sqlserver oracle数据库连接方式
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
L1-027 rental (Lua)
Boot 和 Cloud 的版本选型
IP tools
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
【STL】vector
R语言使用ggplot2函数可视化需要构建泊松回归模型的计数目标变量的直方图分布并分析构建泊松回归模型的可行性
怎么在手机上买股票开户 股票开户安全吗
what‘s the meaning of inference