0686. Repeated String Match
https://leetcode.com/problems/repeated-string-match
Description
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"
.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= a.length <= 104
1 <= b.length <= 104
a
andb
consist of lower-case English letters.
ac
Last updated