Count The Repetitions LeetCode solution in Python
1class Solution:2def getMaxRepetitions(self, s1: str, n1: int, s2: str, n2: int) -> int:3dp = []4for i in range(len(s2)):5start = i6cnt = 07for j in range(len(s1)):8if s1[j] == s2[start]:9start += 110if start == len(s2):11start = 012cnt += 113dp.append((start, cnt))14res = 015next = 016for _ in range(n1):17res += dp[next][1]18next = dp[next][0]19return res // n2