Repeated Substring Pattern — String Algorithms
Decide whether a short lowercase string is made by repeating a shorter piece of itself several times over.
String Algorithms · Easy
The problem
A wallpaper strip may be a single tile pattern stamped over and over. Decide whether the string can be built by taking some shorter piece of it and writing that piece two or more times in a row.
The story
A wallpaper strip of 1 to 12 lowercase letters may be a single tile stamped over and over. Decide whether the strip is some strictly shorter piece written two or more times in a row.
What to return
- Return true if such a piece exists, false otherwise.
- The piece must be strictly shorter than s, so a string is never "a repeat" of itself.
Constraints
- 1 <= len(s) <= 12
- s uses only lowercase letters a-z
Example
- Input
s = "xyzxyz"- Output
true