当前位置:网站首页>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
边栏推荐
- 力扣 912.排序数组
- Mysql, sqlserver Oracle database connection mode
- 841. String hash
- 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
- R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
- 8 CAS
- [RT thread env tool installation]
- How to buy stocks on your mobile phone and open an account? Is it safe to open an account
- R语言dplyr包select函数、group_by函数、filter函数和do函数获取dataframe中指定因子变量中指定水平中特定数值数据列的值第三大的值
- 多个线程之间如何协同
猜你喜欢
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
mock.js从对象数组中任选数据返回一个数组
openEuler 有奖捉虫活动,来参与一下?
LeetCode_ 7_ five
ASP. Net kindergarten chain management system source code
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
Openeuler prize catching activities, to participate in?
Cloud component development and upgrading
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
随机推荐
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
Browse the purpose of point setting
JVM 类加载机制
MSE API学习
ASP.NET体育馆综合会员管理系统源码,免费分享
841. 字符串哈希
Welcome to the markdown editor
Kubernetes——kubectl命令行工具用法详解
UCloud是基础云计算服务提供商
Interpretation of transpose convolution theory (input-output size analysis)
[auto.js] automatic script
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
IP tools
开源OA开发平台:合同管理使用手册
Ucloud is a basic cloud computing service provider
My creation anniversary
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
小试牛刀之NunJucks模板引擎
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
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record