image.png
    题目描述:
    image.png
    [题目Link: https://leetcode-cn.com/problems/repeated-substring-pattern/]


    My answer:

    1. class Solution(object):
    2. def repeatedSubstringPattern(self, s):
    3. """
    4. :type s: str
    5. :rtype: bool
    6. """
    7. candi = set()
    8. for i in range(int(len(s)/2 +1)):
    9. candi.add(s[:i])
    10. candi = [i for i in candi if len(i) > 0]
    11. for i in candi:
    12. if int(len(s)/len(i)) * i == s:
    13. return True
    14. return 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