
题目描述:
[题目Link: https://leetcode-cn.com/problems/repeated-substring-pattern/]
My answer:
class Solution(object):def repeatedSubstringPattern(self, s):""":type s: str:rtype: bool"""candi = set()for i in range(int(len(s)/2 +1)):candi.add(s[:i])candi = [i for i in candi if len(i) > 0]for i in candi:if int(len(s)/len(i)) * i == s:return Truereturn False
(cost 4 pomos)
借鉴别人的answer:
def find_ss(s):
for x in range(int(len(s)/2)):
candi = s[0:(x+1)]
beishu = int(len(s)/(x+1))
if candi * beishu == s:
return True
return False
