Simple sliding window solution 😊
IntuitionApproachComplexity
Time complexity:

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

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

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

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

# Code
```cpp []
class Solution {
public:
    int numberOfSubstrings(string s, int k) {

        int i = 0;
        int j = 0;
        unordered_map<char,int>mp;
        int ans = 0;
        int n = s.size() - 1;
        while(i < s.size() && j < s.size()){
         mp[s[j]]++;
         if(mp[s[j]] == k){
             while(mp[s[j]] == k){
                ans += n - j + 1;
                mp[s[i]]--;
                i++;
             }
         }
         j++;

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