Repeated Substring Pattern

STRING

Problem

Given a string pattern, check if the string can be formed by taking a substring of it and repeating it multiple times. Return true if such a pattern exists, otherwise return false.

Examples

isRepeatingPattern("zyzy") // returns true // It's the pattern "zy" repeated twice. isRepeatingPattern("xyx") // returns false isRepeatingPattern("mnmnmn") // returns true // It's the pattern "mn" repeated three times.
Loading...