Solution in Java 100%
\n\n# Code\n\nclass Solution {\n    public int getMaxRepetitions(String s1, int n1, String s2, int n2) {\n         int l1 = s1.length(), l2 = s2.length();\n    
\n\n# Code\n```\nclass Solution {\n    public int getMaxRepetitions(String s1, int n1, String s2, int n2) {\n         int l1 = s1.length(), l2 = s2.length();\n        int[] next = new int[l2 + 1];\n        int[] count = new int[l2 + 1];\n        int cnt = 0, p = 0;\n        for (int i = 0; i < n1; i++) {\n            for (int j = 0; j < l1; j++) {\n                if (s1.charAt(j) == s2.charAt(p)) {\n                    p++;\n                }\n                if (p == l2) {\n                    cnt++;\n                    p = 0;\n                }\n            }\n            count[i] = cnt;\n            next[i] = p;\n            for (int j = 0; j < i; j++) {\n                if (next[j] == p) {\n                    int prev_count = count[j];\n                    int pattern_count = (count[i] - count[j]) * ((n1 - j - 1) / (i - j));\n                    int remain_count = count[j + (n1 - j - 1) % (i - j)] - count[j];\n                    return (prev_count + pattern_count + remain_count) / n2;\n                }\n            }\n        }\n        return count[n1 - 1] / n2;\n    }\n}\n```
['String', 'Dynamic Programming', 'Java']