Simple Pythonic Solution


  • 0
    A
    class Solution(object):
        def repeatedSubstringPattern(self, str):
            """
            :type str: str
            :rtype: bool
            """
            l = len(str)
            for i in range(l//2):
                if l % (i+1) == 0:
                    if str[:i+1]*(l/(i+1)) == str:
                        return True
            return False
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.