C++ sliding window approach Time: O(n) Space: O(n) beat 100%!!
Approachkeeps open window till find there is a char freq is greater than k,
and all the subarray including current one will all be the answer.Once we update the
# Approach
<!-- Describe your approach to solving the problem. -->
keeps open window till find there is a char freq is greater than k,
and all the subarray including current one will all be the answer.

Once we update the answer then close window to check the condition still meet or not
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(n)$$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$$O(n)$$

# Code
```cpp []
class Solution {
public:
    int numberOfSubstrings(string s, int k) {
        // setup freq table and the window pointer and answer counter
        unordered_map<char, int> table;
        int left = 0;
        int right = 0;
        int ans = 0;

        // sliding window
        while(right < s.size()){
            // update freq table
            table[s[right]]++;

            // find at least one char >= k times
            // get the subarray ans (all possible sub to the right)
            // close window
            while(table[s[right]] >= k){
                ans += s.size() - right;
                table[s[left]]--;
                left++;
            }

            // open window
            right++;
        }

        return ans;
    }
};
```
['C++']