easiest JAVA solution by creating a frequency array.... BRUTE FORCE ....
Intuition\n Describe your first thoughts on how to solve this problem. \napplying sliding window approach and keeping track of the frequency of characters and  
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\napplying sliding window approach and keeping track of the frequency of characters and  counting valid substrings \n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirst increase the size of the window until you get a substring that satisfies the given condition and calculate the no of substrings then minimize the size of the window and count the valid substrings utnill the condition voilates again and repeat this process till you reach the end of the string\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 l = 0;\n        int r = 0;\n        int count[] = new int[26];\n        int n = s.length();\n        int ans = 0;\n\n        while (r < n) {\n            char ch = s.charAt(r);\n            count[ch - \'a\']++;\n\n            boolean check = helper(count, k);\n\n            if (check == true) {\n                ans += n - r;\n\n                while (l <= r) {\n\n                    count[s.charAt(l) - \'a\']--;\n                    l++;\n                    boolean check1 = helper(count, k);\n                    if (check1) {\n                        ans += n-r;\n                    } else {\n                        break;\n                    }\n                }\n            }\n            r++;\n        }\n\n        return ans;\n\n    }\n\n    public static boolean helper(int count[], int k) {\n\n        for (int i = 0; i < 26; i++) {\n            if (count[i] == k) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n}\n```
['Java']