Easy O(n1 + ns2*ns2) approach
Intuition\n Describe your first thoughts on how to solve this problem. \nEntire Thought process in the comments.\n\n\n# Complexity\n- Time complexity:\n Add you
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nEntire Thought process in the comments.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n1 + ns2*ns2)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(ns2)\n\n# Code\n```\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        // dp[i] = no of new blocks of s1 required to construct 1 block of str2 starting from s1[i]\n        // next[i] = index of s1 obtained after constructing 1 block of str2 using dp[i] blocks\n        // int blocks = 0, ind = 0, m = 0;\n        // while (blocks + dp[ind] <= n) {\n            // blocks += dp[ind];\n            // ind = next[ind];\n            // m++;\n        // }\n        //  return m;\n        // TLE (10^ 6 * 100)\n        // revision\n        // dp[i] = no of characters of str2 satisfied for 1 block of s1 if str2 started at str2[i]\n        // int ns2 = s2.size();\n        // for (int i = 0, ind = 0, cnt = 0; i < n; i++) {\n        //     cnt += dp[ind];\n        //     ind = (ind + dp[ind]) % ns2 * n2;\n        // }\n        // return cnt / ns2 / n2 ;\n        // but dp will have a size of ns2 (10 ^ 6 * 100)\n        // TLE , MLE\n        // can we reduce this size by leveraging periodicity of str2\n        // revision\n        // dp[i] = no of characters of str2 satisfied for 1 block of s1 if s2 started at s2[i]\n        // int ns2 = s2.size();\n        // for (int i = 0, ind = 0, cnt = 0; i < n; i++) {\n        //     cnt += dp[ind];\n        //     ind = (ind + dp[ind]) % ns2;\n        // }\n        // return cnt / ns2 / n2 ;\n        // brute force dp (100 * 100);\n        // for (int ind = 0; ind < ns2; ind++) {\n        //     int l1 = 0, l2 = ind, cnt = 0;\n        //     while (l1 < ns1) {\n        //         if (s1[l1] == s2[l2]) {\n        //             l2++;\n        //             l2 %= ns2;\n        //             cnt++;\n        //         }\n        //         l1++;\n        //     }\n        //     dp[ind] = cnt;\n        // }\n        int ns1 = s1.size(), ns2 = s2.size();\n        vector<int> dp(ns2, 0);\n        for (int ind = 0; ind < ns2; ind++) {\n            int l1 = 0, l2 = ind, cnt = 0;\n            while (l1 < ns1) {\n                if (s1[l1] == s2[l2]) {\n                    l2++;\n                    l2 %= ns2;\n                    cnt++;\n                }\n                l1++;\n            }\n            dp[ind] = cnt;\n        }\n        int cnt = 0;\n        for (int i = 0, ind = 0; i < n1; i++) {\n            cnt += dp[ind];\n            ind = (ind + dp[ind]) % ns2;\n        }\n        return cnt / ns2 / n2 ;\n    }\n};\n```
['C++']