Ugly Java brute force solution, but accepted. 1088ms.
I didn't come up with any good solution so I tried brute force. Key points:\n1. How do we know "string s2 can be obtained from string s1"? Easy, use two pointer
I didn't come up with any good solution so I tried brute force. Key points:\n1. How do we know "string s2 can be obtained from string s1"? Easy, use two pointers iterate through s2 and s1. If chars are equal, move both. Otherwise only move pointer1.\n2. We repeat step 1 and go through s1 for n1 times and count how many times can we go through s2.\n3. Answer to this problem is times go through s2 divide by n2.\n\n```\npublic class Solution {\n    public int getMaxRepetitions(String s1, int n1, String s2, int n2) {\n        char[] array1 = s1.toCharArray(), array2 = s2.toCharArray();\n        int count1 = 0, count2 = 0, i = 0, j = 0;\n        \n        while (count1 < n1) {\n            if (array1[i] == array2[j]) {\n                j++;\n                if (j == array2.length) {\n                    j = 0;\n                    count2++;\n                }\n            }\n            i++;\n            if (i == array1.length) {\n                i = 0;\n                count1++;\n            }\n        }\n        \n        return count2 / n2;\n    }\n}\n```
[]