当前位置:网站首页>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
边栏推荐
- Cloud 组件发展升级
- 9 原子操作类之18罗汉增强
- Ucloud is a basic cloud computing service provider
- 数据孤岛是企业数字化转型遇到的第一道险关
- Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
- pom. Brief introduction of XML configuration file label function
- Sword finger offer II 013 Sum of two-dimensional submatrix
- 【STL】vector
- Interpretation of transpose convolution theory (input-output size analysis)
- 剑指 Offer II 013. 二维子矩阵的和
猜你喜欢

Openeuler prize catching activities, to participate in?

ASP. Net kindergarten chain management system source code

Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse

Flink并行度和Slot详解

Ways to improve the utilization of openeuler resources 01: Introduction

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

YoloV6:YoloV6+Win10---训练自己得数据集

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

The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared

MRS离线数据分析:通过Flink作业处理OBS数据
随机推荐
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
Cuda版本不一致,编译apex报错
mysql 的一些重要知识
【STL】vector
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
LC: string conversion integer (ATOI) + appearance sequence + longest common prefix
UCloud是基础云计算服务提供商
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
JVM GC垃圾回收简述
开源OA开发平台:合同管理使用手册
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
mock.js从对象数组中任选数据返回一个数组
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
R语言dplyr包select函数、group_by函数、filter函数和do函数获取dataframe中指定因子变量中指定水平中特定数值数据列的值第三大的值
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
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
银行理财产品怎么买?需要办银行卡吗?
多个线程之间如何协同