Share my python solution, detailed thought (while not elegant)
python\nclass Solution(object):\n    def getMaxRepetitions(self, s1, n1, s2, n2):\n        """\n        :type s1: str\n        :type n1: int\n        :type s2: 
```python\nclass Solution(object):\n    def getMaxRepetitions(self, s1, n1, s2, n2):\n        """\n        :type s1: str\n        :type n1: int\n        :type s2: str\n        :type n2: int\n        :rtype: int\n        """\n        # First, try to find s2 inside s1\n        \n        L1 = len(s1)\n        L2 = len(s2)\n        i = 0\n        j = 0\n        count = 0\n        while i < L1:\n            \n            if s1[i] == s2[j]:\n                j += 1\n                if j == L2:\n                    count += 1\n                    j = 0\n            \n            i += 1\n            \n        # cannot find any single character of s2\n        if count == 0 and j == 0:\n            return 0\n            \n        # s1 contains at least one s2\n        # concat two s1, we may find one more s2\n        if count > 0:\n            tmp = count\n            i = 0\n            while i < L1:\n                if s1[i] == s2[j]:\n                    j += 1\n                    if j == L2:\n                        count += 1\n                        j = 0\n            \n                i += 1\n        \n\t    # no more s2 after concat\n            if tmp * 2 == count:\n                return tmp * n1 / n2\n            # we do have one more s2 after concat\n            else:\n                return (tmp * n1 + n1 - 1) / n2 if n1 > 0 else 0\n                \n        # Here count == 0, j != 0, means only part of s2 is found inside s1, in other words, we got a "dirty tail"\n        # concat more s1 until we find a complete s2, and keep finding new s2, until the "dirty tail" is gone or remains the same, which means we finally find the pattern\n        \n        tmp = -1\n        accArr = []\n        acc = 1\n        while j != 0 and j != tmp:\n            tmp = j\n \n            s1Num = 0\n            findS2 = False\n            while not findS2:\n                s1Num += 1\n                i = 0\n                hit = False\n                while i < L1:\n                    if s1[i] == s2[j]:\n                        hit = True\n                        j += 1\n                        if j == L2:\n                            findS2 = True\n                            count += 1\n                            j = 0\n                \n                    i += 1\n                    \n                if not hit: # cannot find necessary characters\n                    return 0\n                    \n            accArr.append(acc + s1Num) # accArr[i] = how many s1 are checked when we find i th complete s2\n            acc += s1Num\n            if acc > n1:\n                return (count - 1) / n2\n            \n        # pattern found!\n    \n        if j == 0:\n            # (acc) number of s1 = (count) number of s2\n            S = n1 / acc * count\n            r = n1 % acc\n\n            for num in accArr:\n                if num <= r:\n                    S += 1\n                else:\n                    break\n\n            return S / n2\n            \n        if j == tmp:\n            # (acc) number of s1 = (count) number of s2\uff0cnow every new (s1Num) number of s1, gives us a new s2\n            return ( (n1 - acc) / s1Num + count) / n2\n```
[]