Repeated Substring Pattern

Easy

Given a string s, return true if it can be built by repeating one of its substrings several times.

Example 1

repeatedSubstringPattern()
Input
s = "abab"
Output
true

Why

It is "ab" twice.

Example 2

repeatedSubstringPattern()
Input
s = "aba"
Output
false
Constraints
1 <= s.length <= 10^4
`s` consists of lowercase English letters.

Topics

StringsString Matching

Implement repeatedSubstringPattern in the editor and return the answer — printing it is never graded.