sliding window solution|| hard made easy || java solution
Intuition\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim
# Intuition\n![Screenshot 2024-09-01 001054.png](https://assets.leetcode.com/users/images/622ca1a1-aed0-4618-828b-0927d8d132a2_1725129672.1689324.png)\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    int solve(int start, int end, String str, int k) {\n        int res = 0;\n        for (int uc = 1; uc <= 26 && uc * k <= end - start + 1; uc++) {\n            int wl = uc * k;\n            int count = 0;\n            int i = start;\n            int[] arr = new int[26];\n            for (int j = start; j <= end; j++) {\n                arr[str.charAt(j) - \'a\']++;\n                if (arr[str.charAt(j) - \'a\'] == k)\n                    count++;\n                else if (arr[str.charAt(j) - \'a\'] == k + 1)\n                    count--;\n                if (j - i + 1 > wl) {\n                    if (arr[str.charAt(i) - \'a\'] == k)\n                        count--;\n                    else if (arr[str.charAt(i) - \'a\'] == k + 1)\n                        count++;\n                    arr[str.charAt(i) - \'a\']--;\n                    i++;\n                }\n                if (count == uc)\n                    res++;\n            }\n        }\n        return res;\n    }\n\n    public int countCompleteSubstrings(String word, int k) {\n        int n = word.length();\n        int last = 0;\n        int result = 0;\n        for (int i = 1; i <= n; i++) {\n            if (i == n || Math.abs(word.charAt(i) - word.charAt(i - 1)) > 2) {\n                result += solve(last, i - 1, word, k);\n                last = i;\n            }\n        }\n        return result;\n    }\n}\n\n```
['Java']