364. Minimum Repetations
Given two strings a and b, determine the minimum number of times string a must be repeated so that string b becomes a substring of the repeated string.
If it is impossible for b to be a substring of the repeated string a, return -1.
Example 1:
Input: a = "xyz", b = "yzxyzx"
Output:3
Explanation:
By repeating a three times (xyzxyzxyz), b becomes a substring. Thus, the output is 3.
Example 2:
Input: a = "ab", b = "ababab"
Output: 3
Explanation:
By repeating a three times (ababab), b becomes a substring. Thus, the output is 3.
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= a.length, b.length <= 105