c++ clean sliding window
we break the word into words that fullfill the adjacent character requirement. then we slide window size from k to 26* k for each word to see how many complete 
we break the word into words that fullfill the adjacent character requirement. then we slide window size from k to 26* k for each word to see how many complete substr there is\n\n# Code\n```\nclass Solution {\npublic:\n    inline int isvalid(vector<int> &window, int k, string &word, int l, int r){\n        for (int i=0; i< window.size();i++){\n            if (window[i] && window[i] != k ) return 1;//invalid\n        }\n        return 0;//valid\n    }\n    int slide (string &word, int windowlength, int k, vector<int> &window){\n        int left = 0;\n        int right = windowlength;\n        int count = 0;\n        for (int i=0; i< windowlength;i++){\n            window[int(word[i])-97]++;\n        }//initial window\n        if (!isvalid(window,k,word,left,right-1)) count ++;\n        while (right < word.size()){\n             window[int(word[right])-97]++;\n             window[int(word[left])-97]--;\n             if (!isvalid(window,k,word,left+1,right)) count ++;\n             right ++;\n             left ++;\n        }\n        return count;\n    }\n    int countCompleteSubstrings(string word, int k) {\n        int res = 0;\n        vector<string> w;\n        string s = word.substr(0,1);\n        for (int i=1; i< word.size();i++){\n            if (abs(word[i]-word[i-1]) >2){\n                w.push_back(s);\n                s = word.substr(i,1);\n            } else{\n                s += word[i];\n            }\n        }\n        if (s.size()) w.push_back(s);\n        for (int ws = k; ws<=26*k;ws+=k){\n            for (auto &x:w){\n                if (ws > x.size()) {\n                    continue;\n                }\n                vector<int> w(26,0);\n                res += slide(x,ws,k,w);\n            }\n\n        }\n        return res;\n    }\n};\n```
['C++']