📌📌Easy to understand solution📌📌 | Beginner-friendly✅✅
Complexity
Time complexity: O(n)

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

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

# Code
```cpp []
class Solution {
public:
    int numberOfSubstrings(string s, int k) {
        int n = s.length();
        unordered_map<char, int> mp;
        int l = 0, r = 0, ans = 0;
        while (r < n) {
            mp[s[r]]++;
            while (mp[s[r]] >= k) {
                mp[s[l]]--;
                l++;
            }
            ans+=(r-l+1);
            r++;
        }
        return n * (n+1) / 2 - ans;
    }
};
```
['Sliding Window', 'C++']