java solution using sliding window and hashmap
Intuition\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 
# Intuition\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    public int numberOfSubstrings(String s, int k) {\n        int i=0;int ans=0;int n =s.length();\n        HashMap<Character,Integer> map=new HashMap<>();\n        for(int j=0;j<s.length();j++) {\n            char ch =s.charAt(j);\n            map.put(ch,map.getOrDefault(ch,0)+1);\n            if(map.get(ch)>=k) {\n                while(i<=j && map.get(ch)>=k ) {\n                    map.put(s.charAt(i),map.get(s.charAt(i))-1);\n                        i++;\n                ans+= n-j;\n                }\n            }\n\n        }\n\n        return ans;\n    }\n}\n```
['Java']