Java Easy Solution 🚀 | Beats 96% 💥 |  Sliding Window
I have Explained every line of code using comments. Hope u like it :)\n\nclass Solution {\n    public int countCompleteSubstrings(String word, int k) {\n       
I have Explained every line of code using comments. Hope u like it :)\n```\nclass Solution {\n    public int countCompleteSubstrings(String word, int k) {\n        \n        int n = word.length();\n        int lastIndex = 0;\n        int result = 0;\n\n        //Dividing borders according to condition-2     "aa | ddff | kk"\n        for(int i=1; i<=n; i++){\n            //i==n because we need to check for last division too\n            if(i==n || Math.abs(word.charAt(i) - word.charAt(i-1)) > 2){\n\n                result += solve(lastIndex, i-1, word, k);\n                lastIndex = i;\n            }\n        }\n        return result;\n    }\n    //Now checking for condition-1 Using Sliding Window\n    public int solve(int start, int end, String word, int k){\n\n        int result = 0;\n\n        //Now we need to find for every Unique character occourace == k\n        //agar 1 uniq char hai string me or k=2 hai means total unique characters <= string length hona chahiye \n        for(int unique_Char = 1; unique_Char <= 26 && unique_Char * k <= end - start + 1; unique_Char++){\n\n            int[] freqMap = new int[26];\n            int goodChar = 0;\n\n            //Now using sliding window to find goodChar present in string\n            int i = start;\n            int j = start;\n            int windowLength = unique_Char * k;\n\n            while(j <= end){\n\n                char ch = word.charAt(j);   //calculation part\n\n                freqMap[ch - \'a\']++;\n\n                if(freqMap[ch - \'a\'] == k){\n                    goodChar++;\n                }\n                else if(freqMap[ch - \'a\'] == k + 1){\n                    goodChar--;\n                }\n\n                if(j - i + 1 > windowLength){   //if window size is greater \n                    \n                    char c = word.charAt(i);     //then remove the calculation using i\n\n                    if(freqMap[c - \'a\'] == k){\n                        goodChar--;\n                    }\n                    else if(freqMap[c - \'a\'] == k + 1){\n                        goodChar++;\n                    }\n\n                    freqMap[c - \'a\']--;\n                    i++;    //slide the window\n                }\n                if(goodChar == unique_Char){    //if goodChar == unique_Char means we found a character whose occurence is exact k\n                    result++;\n                }\n                j++;    //slide the window\n            }\n        }\n        return result;  //return totalGood chars present in this substring\n    }\n}\n```
['Sliding Window', 'Java']