Using sliding window
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. first divide the substrin
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->first divide the substring according to difference between character if greater than2 then for each substring check that it is good or using sliding window .\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ --> o(n^2)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --> o(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int solve(int start,int end,string &word,int k){\n        int ans=0;\n        for(int uniqueChar=1;uniqueChar<=26&&uniqueChar*k<=end-start+1;uniqueChar++){\n            vector<int> freq(26,0);\n            int i=start;\n            int goodChar=0;\n            int windowLen=uniqueChar*k;\n            for(int j=start;j<=end;j++){\n                char ch=word[j];\n                freq[ch-\'a\']++;\n                if(freq[ch-\'a\']==k) goodChar++;\n                else if(freq[ch-\'a\']==k+1)goodChar--;\n\n\n                if(j-i+1>windowLen){\n                    if(freq[word[i]-\'a\']==k) goodChar--;\n                    else if(freq[word[i]-\'a\']==k+1)goodChar++;\n                    freq[word[i]-\'a\']--;\n                    i++;\n                }\n            if(goodChar==uniqueChar) ans+=1;\n            }\n        }\n        return ans;\n    }\n    int countCompleteSubstrings(string word, int k) {\n        int last=0;\n        int ans=0;\n        int n=word.size();\n        for(int i=1;i<=word.size();i++){\n            if(i==n||abs(word[i]-word[i-1])>2){\n                ans+= solve(last,i-1,word,k);\n            last=i;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']