Maximum Repeating Substring

EasyString

Description

Given a string sequence and a word, return the maximum k-repeating value where word repeated k times is a substring of sequence.

Examples

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

"ab" repeated 2 times is "abab", which is a substring of "ababc". So the maximum repeating value is 2.

Input:sequence = "a", word = "a"
Output:1
Explanation:

The word can appear once but not twice in the sequence. The exact output is 1.

Input:sequence = "aaabaaaaba", word = "aaba"
Output:1
Explanation:

The word can appear once but not twice in the sequence. The exact output is 1.

Constraints

  • 1 ≤ sequence.length ≤ 100

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!