Class Solution
- java.lang.Object
-
- g0401_0500.s0466_count_the_repetitions.Solution
-
public class Solution extends Object
466 - Count The Repetitions.Hard
We define
str = [s, n]
as the stringstr
which consists of the strings
concatenatedn
times.- For example,
str == ["abc", 3] =="abcabcabc"
.
We define that string
s1
can be obtained from strings2
if we can remove some characters froms2
such that it becomess1
.- For example,
s1 = "abc"
can be obtained froms2 = "ab**dbe**c"
based on our definition by removing the bolded underlined characters.
You are given two strings
s1
ands2
and two integersn1
andn2
. You have the two stringsstr1 = [s1, n1]
andstr2 = [s2, n2]
.Return the maximum integer
m
such thatstr = [str2, m]
can be obtained fromstr1
.Example 1:
Input: s1 = “acb”, n1 = 4, s2 = “ab”, n2 = 2
Output: 2
Example 2:
Input: s1 = “acb”, n1 = 1, s2 = “acb”, n2 = 1
Output: 1
Constraints:
1 <= s1.length, s2.length <= 100
s1
ands2
consist of lowercase English letters.1 <= n1, n2 <= 106
- For example,
-
-
Constructor Summary
Constructors Constructor Description Solution()
-