In constant space,simple approach
CodeComplexity
Time complexity:
O(n1*s1.size())
Space complexity:
O(1)
# Code\n```cpp []\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        int i=0,j=0,n=s1.size(),m=s2.size(),ct1=0,cnt=0,count1=0,count2=0;\n        int size1=n1*n,size2=n2*m;\n\n        while(count1<size1){\n                if(s1[i]==s2[j]){\n                    if(j==m-1) j=0;\n                    else j++;\n                    count2++;\n                if(size2==count2) cnt++,count2=0;\n           }\n           if(i==n-1) i=0;\n           else i++;\n        count1++;\n        }\n        return cnt;\n    }\n};\n#Note:\ndont use unecessary arithmetic operations it may give **Bold**tle..\n```\n# Complexity\n- Time complexity:\nO(n1*s1.size())\n- Space complexity:\n- O(1)
['String', 'C++']