Very clean and short 7ms Java solution based on @70664914 's idea
Based on idea here: https://discuss.leetcode.com/topic/70667/c-0ms-o-str1-length-str2-length\nThanks to @70664914 \nAdded some early stop\nJava\npublic class So
Based on idea here: https://discuss.leetcode.com/topic/70667/c-0ms-o-str1-length-str2-length\nThanks to @70664914 \nAdded some early stop\n```Java\npublic class Solution {\n    public int getMaxRepetitions(String s1, int n1, String s2, int n2) {\n        int[] reps = new int[102];\n        int[] rests = new int[102];\n        int posRest=0, repTime=0;\n        int i=0, k=0;\n        if(n1 <= 0) return 0;\n        while(k==i) {\n            i++;\n            for(int j=0; j<s1.length(); j++) {\n                if(s2.charAt(posRest) == s1.charAt(j)) {\n                    posRest++;\n                    if(posRest == s2.length()) {\n                        repTime++;\n                        posRest=0;\n                    }\n                }\n            }\n            if(i >= n1)\n                return repTime / n2;\n            for(k=0; k<i; k++){\n                if(posRest == rests[k])\n                    break;\n            }\n            reps[i] = repTime;\n            rests[i] = posRest;\n        }\n        int interval = i-k;\n        int repeatCount = (n1-k) / interval;\n        int repeatTimes = repeatCount * (reps[i]-reps[k]);\n        int remainTimes = reps[(n1-k) % interval + k];\n        return (repeatTimes + remainTimes) / n2;\n    }\n}\n```
[]