#466

Count The Repetitions

international master · 1935 · lc hard +32 · verified · 33.8% accepted · 446 likes · top 11%

play →

Description

Use [s, n] to mean string s concatenated n times. String a can be "obtained" from string b when a is a subsequence of b (some characters of b may be removed).

Given strings s1, s2 and integers n1, n2, define str1 = [s1, n1] and str2 = [s2, n2]. Return the largest integer m for which [str2, m] can be obtained from str1.

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

Code

1
2
3