CodeStoryWithMik Style
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:O(n * 26 * 2n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(26)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    // int solve(int start, int end, string &s, int k){\n    //     int total=0;\n    //     int n=(end-start+1);\n\n    //     for(int uniqueChar=1; uniqueChar<=26  && (uniqueChar*k)<=n; uniqueChar++){\n    //         int windowSize = uniqueChar*k;\n    //         vector<int> count(n, 0);\n    //         int goodChar=0;\n            \n    //         int l=start, r=end;\n    //         while(r<=n){\n    //             // Calcutating goodChar from \'r\' iterator   \n    //             count[s[r] - \'a\']++;\n\n    //             if(count[s[r]] == k){\n    //                 goodChar++;\n    //             }\n    //             if(count[s[r]] == k+1){\n    //                 goodChar--;\n    //             }\n\n    //             if(r-l+1 > windowSize){ // sliding the window\n    //             // Calcutating goodChar from \'l\' iterator\n    //                 if(count[s[l] - \'a\'] == k){\n    //                     goodChar--;\n    //                 }\n    //                 if(count[s[l] - \'a\'] == k+1){\n    //                     goodChar++;\n    //                 }\n\n    //                 count[s[l] - \'a\']--;\n    //                 l++;\n    //             }\n\n    //             if(goodChar == uniqueChar){\n    //                 total++;\n    //             }\n    //             r++;\n    //         }\n    //     }\n    //     return total;\n    // }\n\n    // int countCompleteSubstrings(string s, int k) {\n    //     int n=s.size();\n        \n    //     int ans=0;\n    //     int border=0;\n    //     for(int i=1; i<=n; i++){\n    //         if(i==n || abs(s[i] - s[i-1]) > 2){ // satisfying condition 2\n    //             ans += solve(border, i-1, s, k); // satisfying condition 1\n    //             border = i;\n    //         }\n    //     }\n\n    //     return ans;\n    // }\n\n     int solve(int start, int end, string &word, int k) {\n        int total = 0;\n        for(int uniqueChar = 1; uniqueChar <= 26 && uniqueChar*k <= end-start+1; uniqueChar++) {\n\n            vector<int> count(26, 0);\n            int goodChars = 0; //How many chars are of frequency k\n\n            //Now do a sliding window\n            int l = start;\n            int windowLength = uniqueChar*k;\n            for(int r = start; r <= end; r++) {\n                char ch = word[r];\n\n                count[ch - \'a\']++;\n                if(count[ch - \'a\'] == k) {\n                    goodChars++;\n                } else if(count[ch - \'a\'] == k+1) {\n                    goodChars--;\n                }\n\n                if(r-l+1 > windowLength) { //Need to shift window right\n                    if(count[word[l] - \'a\'] == k) {\n                        goodChars--;\n                    } else if(count[word[l] - \'a\'] == k+1) {\n                        goodChars++;\n                    }\n                    count[word[l] - \'a\']--;\n                    l++;\n                }\n\n                if(goodChars == uniqueChar) {\n                    total++;\n                }\n\n            }\n\n        }\n\n        return total;\n\n    }\n\n    int countCompleteSubstrings(string s, int k) {\n        int n = s.length();\n\n        int ans = 0;\n        int border = 0;\n\n        for(int i = 1; i <= n; i++) {\n            if(i == n || abs(s[i] - s[i-1]) > 2) { //satisying condition 2\n                ans += solve(border, i-1, s, k); //condition 1\n                border = i;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['Sliding Window', 'C++']