Ruby Solution


  • 0
    G
    def repeated_substring_pattern(str)
        l = str.length
        for i in 1..l/2 do 
            if l%i==0 then 
                    res=str[0,i]*(l/i)
                    return true if str==res
            end
        end
        return false
    end
    

Log in to reply
 

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