当前位置:网站首页>力扣 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
边栏推荐
- mock.js从对象数组中任选数据返回一个数组
- 时间工具类
- Tp6 realize Commission ranking
- 9 atomic operation class 18 Rohan enhancement
- Cloud 组件发展升级
- ant desgin 多选
- Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
- Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
- MySQL、sqlserver oracle数据库连接方式
- 强化学习-学习笔记8 | Q-learning
猜你喜欢
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
9 atomic operation class 18 Rohan enhancement
Redis master-slave and sentinel master-slave switchover are built step by step
多个线程之间如何协同
Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
【STL】vector
Sword finger offer II 013 Sum of two-dimensional submatrix
Interpretation of transpose convolution theory (input-output size analysis)
LeetCode_ 7_ five
随机推荐
Detailed explanation of Flink parallelism and slot
Compiler optimization (4): inductive variables
Simulate the implementation of string class
R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
Welcome to the markdown editor
模拟实现string类
关于自身的一些安排
R language ggplot2 visualization: use the ggqqplot function of ggpubr package to visualize the QQ graph (Quantitative quantitative plot)
R language dplyr package select function, group_ The by function, filter function and do function obtain the third largest value of a specific numerical data column in a specified level in a specified
Semantic SLAM源码解析
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
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry
华南X99平台打鸡血教程
pom.xml 配置文件标签作用简述
开源OA开发平台:合同管理使用手册
JVM 类加载机制
What does "true" mean
Notes...
Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference