Skip to content

Practice Maximum Repeating Substring

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1668
LeetCode Problem

Maximum Repeating Substring

Problem Statement

For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0. Given strings sequence and word, return the maximum k-repeating value of word in sequence.

Source: Maximum Repeating Substring on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
sequence = "ababc", word = "ab"
Output
2

# Example 2

Input
sequence = "ababc", word = "ba"
Output
1

# Example 3

Input
sequence = "ababc", word = "ac"
Output
0

Constraints

1 <= sequence.length <= 100
1 <= word.length <= 100
sequence and word contains only lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Maximum Repeating Substring.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.