Java Easy Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nSolve this problem leveraging only 26 lower alphabets and k value.\n\n# Approach\n Desc
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSolve this problem leveraging only 26 lower alphabets and k value.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst the string will be breaken down in to substring by the adjacent difference condition\nFor each such part now find the count of substring of possible lengths. Suppose k = 3, and the unique alphabets are 2 so answer string length should be 6. Like this the possible answer length will be 3, 6, 9, 12, so on. Use sliding window here to keep the frequency count.\n\n# Code\n```\nclass Solution {\n\n    boolean check(int count[], int k) {\n        for (int i = 0; i < count.length; i++) {\n            if (count[i] != 0 && count[i] != k) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    int solve(char c[], int k) {\n        int ans = 0;\n\n        // check from 1 to 26 unique chars\n\n        for (int i = 1; i <= 26; i++) {\n            // if only i chars, then string length will be i * k\n            int curLen = i * k;\n\n            if (c.length < curLen) {\n                break;\n            }\n\n            int index = 0;\n\n            int freq[] = new int[26];\n\n            while (index < curLen) {\n                freq[c[index] - \'a\']++;\n                index++;\n            }\n\n            if (check(freq, k)) {\n                ans++;\n            }\n\n            while (index < c.length) {\n                freq[c[index - curLen] - \'a\']--;\n                freq[c[index] - \'a\']++;\n                index++;\n\n                if (check(freq, k)) {\n                    ans++;\n                }\n            }\n\n        }\n\n        return ans;\n    }\n\n    public int countCompleteSubstrings(String word, int k) {\n        int ans = 0;\n\n        char c[] = word.toCharArray();\n        StringBuilder sb = new StringBuilder();\n\n        int n = word.length();\n\n        for (int i = 0; i < n; i++) {\n            if (i > 0 && Math.abs(c[i - 1] - c[i]) > 2) {\n                ans = ans + solve(sb.toString().toCharArray(), k);\n                sb = new StringBuilder();\n            }\n\n            sb.append(c[i]);\n        }\n\n        ans = ans + solve(sb.toString().toCharArray(), k);\n\n        return ans;\n    }\n}\n```
['Sliding Window', 'Java']