Use sliding Windows of size k, 2k, 3k,....,26k
Intuition\n Describe your first thoughts on how to solve this problem. \nSince character frequency of any character has to be k, the target substring will alway
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince character frequency of any character has to be k, the target substring will always be of length 1*k, 2*k,3*k\n\nAnd since there are 26 disticnt alphabets, the maximum possible length will be 26*k.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nI run a out loop to track window lenght from k, 2*k,...i*k where i = 1 to 26\n\nIn inner loop, I use sliding window of size i*k and check if it is a complete substring.\n\nIf at any point, two adjacent characters differ by a distance more than 2, I reset the length of the window by moving the left pointer\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(26*n)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n\n# Code\n```\nint check(vector<int>& freq, int k)\n{\n    for(int i:freq)\n    {\n        if(i!=k && i!= 0) return false;\n    }\n    return true;\n}\nclass Solution {\npublic:\n    int countCompleteSubstrings(string word, int k)\n    {\n        int ans =0;\n        for(int i=1;i<=26 && i*k<= word.size();i++)\n        {\n            vector<int> freq(26,0);\n            int left =0, right=0;\n            while(right<word.size())\n            {\n                freq[word[right++]-\'a\']++;\n                if(right-left>=i*k)\n                {\n                    if(check(freq,k)) ans++;\n                    freq[word[left++]-\'a\']--;\n                }\n                if(right<word.size() && abs(word[right]-word[right-1])>2)\n                {\n                    while(left<right) freq[word[left++]-\'a\']--;\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']