PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates string manipulation and pattern recognition skills, focusing on detection of repeated substring patterns, string periodicity, and handling of boundary conditions.

  • easy
  • Beaconfire
  • Coding & Algorithms
  • Machine Learning Engineer

Check Whether a String Is Built by Repetition

Company: Beaconfire

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Given a non-empty string `s`, determine whether it can be constructed by repeating one of its non-empty proper substrings two or more times. A proper substring used for repetition must be shorter than `s`. Implement a function: ```python def is_repeated_pattern(s: str) -> bool: pass ``` Return `True` if such a substring exists, otherwise return `False`. Examples: ```text Input: s = "abab" Output: True Explanation: "ab" repeated twice forms "abab". Input: s = "aba" Output: False Input: s = "abcabcabc" Output: True Explanation: "abc" repeated three times forms "abcabcabc". ``` Constraints: - `1 <= len(s) <= 10^4` - `s` contains lowercase English letters only.

Quick Answer: This question evaluates string manipulation and pattern recognition skills, focusing on detection of repeated substring patterns, string periodicity, and handling of boundary conditions.

Given a non-empty string `s`, determine whether it can be constructed by repeating one of its non-empty proper substrings two or more times. A proper substring used for repetition must be shorter than the full string. Return `True` if such a substring exists; otherwise return `False`.

Constraints

  • 1 <= len(s) <= 10^4
  • s contains lowercase English letters only

Examples

Input: ("abab",)

Expected Output: True

Explanation: "ab" repeated 2 times forms "abab".

Input: ("aba",)

Expected Output: False

Explanation: No non-empty proper substring can be repeated to form the full string.

Input: ("abcabcabc",)

Expected Output: True

Explanation: "abc" repeated 3 times forms "abcabcabc".

Input: ("a",)

Expected Output: False

Explanation: A single character cannot be formed by repeating a shorter non-empty proper substring.

Input: ("zzzz",)

Expected Output: True

Explanation: "z" repeated 4 times forms "zzzz".

Input: ("abcdabc",)

Expected Output: False

Explanation: Although parts of the string repeat, no proper substring repeated multiple times builds the entire string.

Hints

  1. If a string is built from repeating a smaller block, its prefix and suffix structure will contain useful overlap information.
  2. Compute the length of the longest proper prefix that is also a suffix. If this overlap is non-zero and the remaining block length divides the full length exactly, the string is repetitive.
Last updated: May 30, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.