466. Count The Repetitions ( beats 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```\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        vector<int> rapport(102,-1);\n        vector<int> rest(102,-1);\n        int b=-1;int posRest=0;int rap=0;\n        int last=-1;\n        rapport[0]=rest[0]=0;\n        for(int i=1;i<=s2.size()+1;i++){\n            int j;\n            for(j=0;j<s1.size();j++){\n                if(s2[posRest]==s1[j]){\n                    posRest++;\n                    if(posRest==s2.size()){\n                        rap++;\n                        posRest=0;\n                    }\n                }\n            }\n            for(int k=0;k<i;k++){\n                if(posRest==rest[k]){b=k;last=i;break;}\n            }\n            rapport[i]=rap;rest[i]=posRest;\n            if(b>=0)break;\n        }\n        int interval=last-b;\n        if(b>=n1)return rapport[n1]/n2;\n        return ((n1-b)/interval*(rapport[last]-rapport[b])+rapport[(n1-b)%interval+b])/n2;  }\n};\n```
['C++']