Sliding Window || C++
Code\n\nclass Solution\n{\npublic:\n    int f(string &word, int k) \n    {\n        int ans=0, len=word.size();\n        for(int w=1; w<=26; w++)\n        {\n  
# Code\n```\nclass Solution\n{\npublic:\n    int f(string &word, int k) \n    {\n        int ans=0, len=word.size();\n        for(int w=1; w<=26; w++)\n        {\n            int window=k*w;\n            if(window>len) break;\n            int i=0, j=0, cnt=0;\n            int m[26]={0};\n            while(j<word.size())\n            {\n                m[word[j]-\'a\']++;\n                if(m[word[j]-\'a\']==k) cnt++;\n                else if(m[word[j]-\'a\']>k)\n                {\n                    while(m[word[j]-\'a\']>k) \n                    {\n                        if(m[word[i]-\'a\']==k) cnt--;\n                        m[word[i++]-\'a\']--;\n                    }\n                }\n                if(j-i+1==window) \n                {\n                    if(cnt==w) ans++;\n                    if(m[word[i]-\'a\']==k) cnt--;\n                    m[word[i++]-\'a\']--;\n                }\n                j++;\n            }\n        }\n        return ans;\n    }\n    int countCompleteSubstrings(string word, int k) \n    {\n        int ans=0, n=word.size();\n        string s="";\n        for(int x=0; x<n; x++)\n        {\n            s+=word[x];\n            if(x<=n-2)\n            {\n                if(abs(word[x]-word[x+1])>2)\n                {\n                    ans+=f(s,k);\n                    s="";\n                }\n            }\n        }\n        ans+=f(s,k);\n        return ans;\n    }\n};\n```
['Array', 'Sliding Window', 'C++']