O(n) Solution beat 100%
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 count=0;
        int left=0;
        int n=s.length();
        unordered_map<char,int>mp;
        for(int r =0;r<s.size();r++){
            mp[s[r]]++;
            while(mp[s[r]]>=k){
                count+=n-r;
                cout<<count<<endl;
                mp[s[left]]--;
                left++;
            }

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