175. Repeated Substring Pattern

EasyStringString

Given a string s, check if it can be constructed by repeating a substring of itself two or more times.

Return 'true' if yes, 'false' otherwise.

Input: A single string s.

Output: Return 'true' if s is formed by repeating a substring, otherwise 'false'.

Examples

Example 1
Input: abab
Output: true
Explanation: 'ab' repeated twice.
Example 2
Input: aba
Output: false
Explanation: No repeating substring can form 'aba'.
Example 3
Input: abcabcabcabc
Output: true
Explanation: 'abc' repeated 4 times.

Constraints

Asked by

GoogleAmazonBloombergMetaMicrosoft
Solve this problem in the editor →