Simple Brute Force Solution
IntuitionIf any character frequency is equal to K then increment the count.Twist if as soon as we find character frequency equal to k then if any other characte
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

If any character frequency is equal to K then increment the count.Twist if as soon as we find character frequency equal to k then if any other characters are left then that cnt of the substring including that characters must also be added.
I used (total length - whereever my j is standing) to find the cnt.
Don't worry let's understand with an example. 

# Approach
<!-- Describe your approach to solving the problem. -->
Why I have used the BruteForce bcz see the constraints.
O(n ^ n) 
if n == 3000 O(3000 * 3000) = 9,000,000.IT CAN run within 1sec so.

Example : S = "a b a c b" K = 2
First iteration 
cnt = 0;
i = 0;
j = 0;
hash[j]++
//Taking an array for visualization
[1,0,0]
[a,b,c]
i = 0;
j = 1;

[1,1,0]
[a,b,c]

j = 2
[2,1,0]
[a,b,c]
*
Now you can see 'j' got a character which has a frequency equal to k
now if we increment the count then count will be only 1
also when i = 0 and j = 3 the freq of c will increase but
but the freq of a is yet equal to two the j has not yet reached n so including 'c' as well there is a substring*
"aba" is a substring
"abac" is also a substring so 
**once I get the char which has frequency equal to two then
totallength - index will get me the remaining frequencies as well.**


Make sure to do a dry runn. 



# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n^2)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(26) For the alphabets

# Code
```java []
class Solution {
    public int numberOfSubstrings(String s, int k) {
        int n = s.length();
        int cnt = 0;
        for(int i = 0 ; i < n ; i++){
            int hash[] = new int[26];
            for(int j = i ; j  < n ; j++){
                hash[s.charAt(j) -'a']++;
                if(hash[s.charAt(j) - 'a'] == k){
                    cnt += n - j;
                    break;
                }
            }
        }
        return cnt;
        
    }
}
```
['Sliding Window', 'Java']