Java contest SOULTION beats 73%
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 n = s.length();\n        int count = 0;       \n        int left = 0, right = 0;   \n        HashMap<Character, Integer> freqMap = new HashMap<>(); \n        while (right < n) {    \n            char rightChar = s.charAt(right);\n            freqMap.put(rightChar, freqMap.getOrDefault(rightChar, 0) + 1);\n            \n            while (validSubstring(freqMap, k)) {\n                \n                count += (n - right); \n                \n               \n                char leftChar = s.charAt(left);\n                freqMap.put(leftChar, freqMap.get(leftChar) - 1);\n                if (freqMap.get(leftChar) == 0) {\n                    freqMap.remove(leftChar);\n                }\n                left++;\n            }\n            \n           \n            right++;\n        }\n        \n        return count;\n    }\n    private boolean validSubstring(HashMap<Character, Integer> freqMap, int k) {\n        for (int freq : freqMap.values()) {\n            if (freq >= k) {\n                return true;\n            }\n        }\n        return false;\n    }\n}\n```
['Java']