C++ | sliding window
ApproachSliding windowComplexity

Time complexity:
O(n*26)


Space complexity:
O(26)

Code
# Approach
Sliding window

# Complexity
- Time complexity:
O(n*26)

- Space complexity:
O(26)

# Code
```cpp []
class Solution {
public:
    bool good(vector<int> &count,int k)
    {
        for(auto &x:count)
           if(x>=k)
             return true;
         return false;    
    }
    int numberOfSubstrings(string s, int k) 
    {
        vector<int>count(26,0);
        int n=s.size(),j=0,i=0,res=0;
        while(j<n)
        {
            count[s[j]-'a']++;
            while(good(count,k))
            {
                res+=(n-j);
                count[s[i]-'a']--;
                i++;
            }
            j++;
        }
        return res;
    }
};
```
['C++']