Maximum Repeating Substring

Easy

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:

abab is substring, ab repeated 2 times.

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

The word "a" repeated 1 time is "a", which is a substring of "a". Repeating 2 times gives "aa" which is not a substring.

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

The word "aaba" repeated 1 time is a substring of "aaabaaaaba". Repeating 2 times gives "aabaaaba" which is not a substring.

Constraints

  • 1 ≤ sequence.length ≤ 100

Ready to solve this problem?

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