Java Solution
Approach\nSince each character must occur exactly k times in a valid substring, the length of any valid substring must be a multiple of k. We only need to consi
# Approach\nSince each character must occur exactly k times in a valid substring, the length of any valid substring must be a multiple of k. We only need to consider substrings of length k * uniqueCharacters, where uniqueCharacters ranges from 1 to the total number of unique characters in word.\n\n# Complexity\n- Time complexity: $$O(N^2)$$\n\n- Space complexity: $$O(k)$$\n\n# Code\n```\nclass Solution {\n    public boolean isEqual(int[] arr, int k) {\n        for (int count : arr) {\n            if (count != 0 && count != k) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    public boolean isAdjacent(String w, int s, int e) {\n        for (int i = s; i < e; i++) {\n            if (Math.abs(w.charAt(i) - w.charAt(i + 1)) > 2) {\n                return false;\n            }\n        }\n        return true;\n    }\n    \n    public int countCompleteSubstrings(String word, int k) {\n        int totalUniqueChars = (int) word.chars().distinct().count();\n        int count = 0;\n\n        for (int uniqueChars = 1; uniqueChars <= totalUniqueChars; uniqueChars++) {\n            int windowSize = uniqueChars * k;\n            if (windowSize > word.length()) {\n                break;\n            }\n\n            int[] charToCount = new int[26];\n            for (int i = 0; i < windowSize; i++) {\n                charToCount[word.charAt(i) - \'a\']++;\n            }\n\n            if (isEqual(charToCount, k) && isAdjacent(word, 0, windowSize - 1)) {\n                count++;\n            }\n\n            for (int start = 1; start <= word.length() - windowSize; start++) {\n                charToCount[word.charAt(start - 1) - \'a\']--;\n                charToCount[word.charAt(start + windowSize - 1) - \'a\']++;\n\n                if (isEqual(charToCount, k) && isAdjacent(word, start, start + windowSize - 1)) {\n                    count++;\n                }\n            }\n        }\n\n        return count;\n    }\n}\n\n```
['Java']