2023-08-21 06:29:54 +0000 UTC

Repeated Substring Pattern

Code

class Solution:
    def repeatedSubstringPattern(self, s: str) -> bool:
        length = len(s)
        for i in range(1, length // 2 + 1):
            if length % i != 0:
                continue
            
            if s == s[:i] * (length // i):
                return True
        
        return False