C++ (beats 100% runtime)
Code\ncpp []\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        vector<bool> letters(\'z\' - \'a\' + 1);\n  
# Code\n```cpp []\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        vector<bool> letters(\'z\' - \'a\' + 1);\n        for (char letter : s1)\n            letters[letter - \'a\'] = true;\n        for (char letter : s2)\n            if (!letters[letter - \'a\'])\n                return 0;\n        int pos1 = 0;\n        int pos2 = 0;\n        unordered_map<int, pair<int, int>> first;\n        for (; pos1 < n1 * s1.size(); ++pos1)\n            if (s1[pos1 % s1.size()] == s2[pos2 % s2.size()])\n            {\n                if (pos2 % s2.size() == 0)\n                {\n                    if (first.contains(pos1 % s1.size()))\n                        break;\n                    first[pos1 % s1.size()] = make_pair(pos1, pos2);\n                }\n                ++pos2;\n            }\n        if (pos1 == n1 * s1.size())\n            return pos2 / s2.size() / n2;\n        int step1 = pos1 - first[pos1 % s1.size()].first;\n        int step2 = pos2 - first[pos1 % s1.size()].second;\n        int count = (s1.size() * n1 - pos1) / step1;\n        pos1 += count * step1;\n        pos2 += count * step2;\n        for (; pos1 < n1 * s1.size(); ++pos1)\n            if (s1[pos1 % s1.size()] == s2[pos2 % s2.size()])\n                ++pos2;\n        return pos2 / s2.size() / n2;\n    }\n};\n```
['C++']