C# Solution || 100.00% Faster
\tpublic class Solution {\n\t\tpublic int GetMaxRepetitions(string s1, int n1, string s2, int n2) \n\t\t{\n\t\t\tint len1 = s1.Length, len2 = s2.Length;\n\t\t\t
\tpublic class Solution {\n\t\tpublic int GetMaxRepetitions(string s1, int n1, string s2, int n2) \n\t\t{\n\t\t\tint len1 = s1.Length, len2 = s2.Length;\n\t\t\tif (len1 == 0 || len2 == 0 || len1 * n1 < len2 * n2)\n\t\t\t\treturn 0;\n\n\t\t\tint[] repeatCnt = new int[len2 + 1];\n\t\t\tint[] nextIdx = new int[len2 + 1];\n\t\t\tint cnt = 0, idx = 0;\n\t\t\tfor (int i = 0; i < n1; i++) \n\t\t\t{\n\t\t\t\tforeach (char c in s1) \n\t\t\t\t{\n\t\t\t\t\tif (c == s2[idx]) \n\t\t\t\t\t{\n\t\t\t\t\t\tidx++;\n\t\t\t\t\t\tif (idx == len2) \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tidx = 0;\n\t\t\t\t\t\t\tcnt++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trepeatCnt[i] = cnt;\n\t\t\t\tnextIdx[i] = idx;\n\t\t\t\tfor (int j = 0; j < i; j++) \n\t\t\t\t{\n\t\t\t\t\tif (nextIdx[j] == idx) \n\t\t\t\t\t{\n\t\t\t\t\t\tint prefixCount = repeatCnt[j];\n\t\t\t\t\t\tint patternCount = (repeatCnt[i] - repeatCnt[j]) * ((n1 - j - 1) / (i - j));\n\t\t\t\t\t\tint suffixCount = repeatCnt[j + (n1 - j - 1) % (i - j)] - repeatCnt[j];\n\t\t\t\t\t\treturn (prefixCount + patternCount + suffixCount) / n2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn repeatCnt[n1 - 1] / n2;\n\t\t}\n\t}
[]