首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
重复的子字符串
[编程题]重复的子字符串
热度指数:1713
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个字符串,请你判断这个字符串是否可以通过重复多次它的子字符串来构成。
数据范围:字符串长度
,保证字符串中仅包含小写英文字母
示例1
输入
"skjl"
输出
false
示例2
输入
"nowcodernowcoder"
输出
true
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(31)
分享
纠错
提交结果有问题?
1个回答
7篇题解
添加回答
0
Python3
多喝牛奶长高高
class Solution:
def repeatSubstring(self , str ):
# write code here
n=len(str)
for i in range(1,n):
if n%i == 0:
if str[:i]*(n/i) ==str:
return True
return False
发表于 2022-03-16 22:54:09
回复(0)
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
字符串
难度:
1条回答
31收藏
1840浏览
热门推荐
通过挑战的用户
查看代码
牛客80527...
2022-09-15 15:18:55
牛客31742...
2022-09-15 10:00:47
刻苦的大熊猫在度假
2022-09-11 19:46:21
宋兵亿
2022-09-08 22:33:26
Previous.
2022-09-07 22:40:46
相关试题
设某二叉树的先序遍历序列为abdg...
树
评论
(1)
游戏内数据分析涉猎的少,如何证明自...
评论
(1)
之前的经历中单品数据分析的经验丰富...
评论
(1)
什么样的人适合做数据分析
评论
(1)
2022 诺瓦科技 Perl re...
perl
System Verilog
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ public boolean repeatSubstring (String str) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ bool repeatSubstring(string str) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return bool布尔型 # class Solution: def repeatSubstring(self , str ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ public bool repeatSubstring (string str) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ function repeatSubstring( str ) { // write code here } module.exports = { repeatSubstring : repeatSubstring };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return bool布尔型 # class Solution: def repeatSubstring(self , str: str) -> bool: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ func repeatSubstring( str string ) bool { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ bool repeatSubstring(char* str ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return bool布尔型 # class Solution def repeatSubstring(str) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ def repeatSubstring(str: String): Boolean = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ fun repeatSubstring(str: String): Boolean { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ public boolean repeatSubstring (String str) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ export function repeatSubstring(str: string): boolean { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ func repeatSubstring ( _ str: String) -> Bool { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return bool布尔型 */ pub fn repeatSubstring(&self, str: String) -> bool { // write code here } }
"skjl"
false
"nowcodernowcoder"
true