Simple Python Solution O(N)

  • 1

    class Solution(object):
    def repeatedSubstringPattern(self, str):

        if str == None:
            return False
        strLen = len(str)
        for i in range(strLen/2):
            substring = str[0:i+1]
            multiplier = strLen/(i+1)
            if str == substring*multiplier:
                return True
        return False


  • 0

    what's the complexity of this algorithm?

Log in to reply

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