o[n] solution in c++
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;
         int ans=0;
         unordered_map<char,int> mp;
         int n=s.length();
         while(j<n)
         {
            char x=s[j];
            mp[x]++;
            while(mp[x]>=k)
            {
                ans+=n-j;
                mp[s[i]]--;
                i++;
            }
            j++;
         }
        return ans;
    }
};
```
['C++']