Design Gurus Logo
Repeated Substring Pattern (easy)

Problem Statement

Given a string s, return true if it can be formed by taking any substring of it and appending multiple copies of the substring together.

A substring is a contiguous sequence of characters in the string.

Examples

  • Example 1:

    • Input: s = "bcdbcdbcdbcd"
    • Expected Output: true
    • Justification: The input string can be formed by repeating the substring "bcd" three times.
  • Example 2:

    • Input: s = "abcdabcd"
    • Expected Output: true
    • Justification: The input string is the result of the substring "abcd" repeated twice.
  • Example 3:

    • Input: s = "aabaaba"
    • Expected Output: false
    • Justification: There's no single substring that, when repeated, forms the input string.

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Unlock this and all other premium problems.
No code editor for this lesson
This lesson focuses on concepts and theory