leetcode:459题
题目:给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成。给定的字符串只含有小写英文字母,并且长度不超过10000。
输入: “abab”
输出: True
输入: “aba”
输出: False
输入: “abcabcabcabc”
输出: True
#python 解法1
class Solution:
def repeatedSubstringPattern(self, s: str) -> bool:
return (s + s).find(s, 1) != len(s)
#python 解法2(暴力)
class Solution:
def repeatedSubstringPattern(self, s: str) -> bool:
# 从起始位置长度倒序截取s长度为1-(len(s)/2)的子串
for i in range(len(s