100% using 2 vectors || Easy Implementation in C++
\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        int len1 = s1.length(), len2 = s2.length();\n        vec
```\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        int len1 = s1.length(), len2 = s2.length();\n        vector<int> repeatCount(len2 + 1, 0);\n        vector<int> nextIndex(len2 + 1, 0);\n\n        int count1 = 0, count2 = 0, j = 0;\n        for (int k = 1; k <= n1; k++) {\n            for (int i = 0; i < len1; i++) {\n                if (s1[i] == s2[j]) {\n                    j++;\n                    if (j == len2) {\n                        j = 0;\n                        count2++;\n                    }\n                }\n            }\n            count1++;\n\n            // Check for repetition pattern\n            repeatCount[k] = count2;\n            nextIndex[k] = j;\n\n            for (int start = 0; start < k; start++) {\n                if (nextIndex[start] == j) {\n                    int prefixCount = repeatCount[start];\n                    int patternCount = (n1 - start) / (k - start) * (repeatCount[k] - repeatCount[start]);\n                    int suffixCount = repeatCount[start + (n1 - start) % (k - start)] - repeatCount[start];\n                    return (prefixCount + patternCount + suffixCount) / n2;\n                }\n            }\n        }\n\n        return count2 / n2;\n    }\n};\n```
['Array', 'String', 'C', 'Counting Sort']