Repeated Substring Pattern

Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.

Example 1
Inputs = "abab"
Outputtrue
It is the substring "ab" twice.
Example 2
Inputs = "aba"
Outputfalse
The string cannot be constructed by repeating a smaller substring multiple times.

Constraints

  • 1 <= s.length <= 10^4
  • s consists of lowercase English letters.

Asked at 8 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate