Practice Repeated String Match
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b to be a substring of a after repeating it, return -1. Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".
Source: Repeated String Match on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
a = "abcd", b = "cdabcdab"
Output
3
# Example 2
Input
a = "a", b = "aa"
Output
2
Constraints
1 <= a.length, b.length <= 10^4
a and b consist of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Repeated String Match.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.