Count complete substrings
Code
# Code
```java []
class Solution {
    public int countCompleteSubstrings(String s, int k) {
        HashSet<Character> set = new HashSet<>();
        int n = s.length();

        for (int i = 0; i < n; i++) {
            char ch = s.charAt(i);
            set.add(ch);
        }
        int size = set.size();
        int ans = 0;

        for (int uni = 1; uni <= size; uni++) {
            HashMap<Character, Integer> map = new HashMap<>();
            int j = 0;
            int ct = 0;
            char prev = s.charAt(0);
            for (int i = 0; i < n; i++) {
                char ch = s.charAt(i);
                if(Math.abs(prev-ch)>2){
                    map = new HashMap<>();
                    prev = ch;
                    j = i;
                    ct = 0;
                }
                map.put(ch, map.getOrDefault(ch, 0) + 1);
                if (map.get(ch) == k) {
                    ct++;
                }

                while(map.get(ch)>k || map.size()>uni){
                    if(map.get(s.charAt(j))==k){
                        ct--;
                    }
                    map.put(s.charAt(j), map.get(s.charAt(j))-1);
                    
                    if(map.get(s.charAt(j))==0){
                        map.remove(s.charAt(j));
                    }
                    j++;
                }

                if(ct==uni && uni==map.size()){
                    ans++;
                }
                prev = ch;
            }
        }

        return ans;
    }
}
```
['Hash Table', 'String', 'Sliding Window', 'Java']