CPP || Sliding Window Concept || Good Questions
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```cpp []\nclass Solution {\npublic:\n    int solve(int start, int end , string &word , int k){\n        int result = 0 ;\n        int l = end -  start +1 ; \n\n        //  uniqe char ; \n        for(int unique_char =1 ;unique_char<= 26 and unique_char*k <= l ; unique_char++){\n            vector<int>count(26,0);\n            int goodboy = 0 ; \n            // sliding window ; \n            int i = start ;\n            int winlen = unique_char*k;\n\n            for(int j = start ; j<=end ; j++){\n                char ch  = word[j];\n                count[ch-\'a\']++ ; \n                if(count[ch-\'a\'] == k){\n                    goodboy++ ; \n                }\n                else if (count[ch-\'a\']==k+1){\n                    goodboy--;\n                }\n\n                if(j-i+1 > winlen){\n                    // ith char index ; \n                    if(count[word[i]-\'a\']==k){\n                        goodboy--;\n                    }\n                    else if (count[word[i]-\'a\']==k+1){\n                        goodboy++ ; \n                    }\n                    count[word[i]-\'a\']--;\n                    i++ ; \n                }\n                if(goodboy==unique_char){\n                    result++ ; \n                }\n            }\n\n        }\n        return result ; \n\n    }\n    int countCompleteSubstrings(string word, int k) {\n        int n = word.length();  \n\n        int ans =0 ;\n        int last =0  ; \n        for(int i=1;i<=n;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        }\n        return ans ; \n    }\n};\n```
['C++']