Skip to content

Practice Count The Repetitions

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#466
LeetCode Problem

Count The Repetitions

Problem Statement

We define str = [s, n] as the string str which consists of the string s concatenated n times. We define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. You are given two strings s1 and s2 and two integers n1 and n2. You have the two strings str1 = [s1, n1] and str2 = [s2, n2]. Return the maximum integer m such that str = [str2, m] can be obtained from str1.

Source: Count The Repetitions on LeetCode. Use the original task for its coding environment and submissions.

Examples

# 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 and s2 consist of lowercase English letters.
1 <= n1, n2 <= 10^6

Related LeetCode Problems

Practice more problems similar to Count The Repetitions.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.