LeetCode 459, Easy. Topics: String, String Matching. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 28 parametrized pytest cases, and a playground notebook:
Problem
Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
Examples
Constraints
- 1 <= s.length <= 10^4
- s consists of lowercase English letters.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026