Class Solution
-
- All Implemented Interfaces:
public final class Solution
686 - Repeated String Match\.
Medium
Given two strings
a
andb
, return the minimum number of times you should repeat stringa
so that stringb
is a substring of it. If it is impossible forb
to be a substring ofa
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:
Input: a = "abcd", b = "cdabcdab"
Output: 3
Explanation: We return 3 because by repeating a three times "abcdabcdabcd", b is a substring of it.
Example 2:
Input: a = "a", b = "aa"
Output: 2
Constraints:
<code>1 <= a.length, b.length <= 10<sup>4</sup></code>
a
andb
consist of lowercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final Integer
repeatedStringMatch(String a, String b)
-
-
Method Detail
-
repeatedStringMatch
final Integer repeatedStringMatch(String a, String b)
-
-
-
-