c++ beat 100%
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```cpp []\nclass Solution {\n    int mp[100][26] = {};\n    int ending[100] = {};\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        int n = s1.size(), m = s2.size();\n        for(int i = 0; i < n; i++)\n            if(!mp[n - 1][s1[i] - \'a\'])\n                mp[n - 1][s1[i] - \'a\'] = 1 + i;\n        for(int i = n - 1; i > 0; i--)\n            for(int j = 0; j < 26; j++)\n                if(mp[i][j])\n                    mp[i - 1][j] = 1 + (s1[i] == \'a\' + j ? 0 : mp[i][j] % n);\n\n        int s2_freq = 0, s1_rep = 0, s1_idx = n - 1, ans = 0;\n        while(true){\n            for(int i = 0; i < m; i++){\n                if(!mp[s1_idx][s2[i] - \'a\']) return 0;\n                s1_idx += mp[s1_idx][s2[i] - \'a\'];\n                s1_rep += s1_idx / n;\n                s1_idx %= n;\n                if(s1_rep > n1) return (ans + s2_freq) / n2;\n            }\n            s2_freq++;\n\n            if(ans) continue;\n\n            if(ending[s1_idx]) {\n                int interval = s1_rep - ending[s1_idx];\n                ans = 1 + (n1 - ending[s1_idx]) / interval * (s2_freq - 1);\n                s1_rep = n1 - (n1 - ending[s1_idx]) % interval;\n                s2_freq = 0;\n            }\n            ending[s1_idx] = s1_rep;\n        }\n    }\n};\n```
['C++']