Simple DP
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\npublic class Solution {\n    public int getMaxRepetitions(String s1, int n1, String s2, int n2) {\n        int n = s1.length();\n        int m = s2.length();\n        if(n * n1 < m * n2) return 0;\n        int[][] dp = new int[s2.length()][2];\n        \n        for(var v : dp) Arrays.fill(v, -1);\n\n        int s1count = 0;\n        int s2count = 0;\n        int s1idx = 0;\n        int s2idx = 0;\n        while(s1count < n1){\n            s1count++;\n            for(char ch : s1.toCharArray()){\n                if(ch == s2.charAt(s2idx)){\n                    s2idx++;\n                    if(s2idx == s2.length()){\n                        s2idx = 0;\n                        s2count++;\n                    }\n                }\n            }\n\n            if(dp[s2idx][0] != -1){\n                int prevs1count = dp[s2idx][0];\n                int prevs2count = dp[s2idx][1];\n\n                int cyclelength = s1count - prevs1count;\n                int cyclecount = (n1 - s1count) / cyclelength ;\n\n                s1count += cyclecount * cyclelength;\n                s2count += cyclecount *(s2count - prevs2count);\n\n            }\n\n            dp[s2idx][0] = s1count;\n            dp[s2idx][1] = s2count;\n        }\n        return s2count / n2;\n    }\n}\n\n```
['Dynamic Programming', 'Java']