tiny c++ code with not tiny explanation
Here is the testcase we will use:\n\nExample 1:\n\nInput: s1 = "acb", n1 = 4, s2 = "ab", n2 = 2\nOutput: 2\n\nIf we expand s1 to acbacbacbacb and s2 infinitely,
Here is the testcase we will use:\n```\nExample 1:\n\nInput: s1 = "acb", n1 = 4, s2 = "ab", n2 = 2\nOutput: 2\n```\nIf we expand ``s1`` to ``acbacbacbacb`` and ``s2`` infinitely, we get\n```\nacbacbacbacb\nabababababababababababab...\n```\nThen we can use a greedy approach to slide pointers over both strings.\nThis code runs in $$O(n1*s1.size())$$, as it will terminate after we have iterated over ``s1`` `n1` times.\n\nSmall note: We have to store the sizes of s1 and s2 in variables so that it won\'t TLE. This solution barely runs in time.\n```\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        int c1 = 0, c2 = 0, i = 0, j = 0, n = s1.size(), m = s2.size();\n        while(c1 < n1) {\n            if(s1[i] == s2[j]) j++;\n            i++;\n            if(i == n) i = 0, c1++;\n            if(j == m) j = 0, c2++;\n        }\n        return c2 / n2;\n    }\n};\n```
['C++']