C++ Sliding Window, （ 100.00% | 87.57%）
IntuitionApproachComplexity
Time complexity:O(n)

Space complexity:O(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    int numberOfSubstrings(string s, int k) {
        vector<int> freq(26, 0);
        int result = 0;
        int i = 0; int n = s.size();
        int j = 0;
        while(i<n && j<n){
            while(j<n){
                freq[s[j]-'a']++;
                if(freq[s[j]-'a']>=k) break;
                j++;
            }
            if(j==n) break;
            int start  = i;
            while(start<=j && freq[s[j]-'a']>=k){
                freq[s[start]-'a']--;
                start++;
            }
            result+=(start-i)*(n-j);
            i = start;          
            j++;
        }
        return result;
    }
};
```
['Sliding Window', 'C++']