Slide Window
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
```csharp []
public class Solution {
    public int NumberOfSubstrings(string s, int k) {
        // slide window:
        int[] sample = new int[26];
        int start = 0, len = s.Length, res = 0;
        if(len < k)
            return res;

        for(int i = 0; i < len; i++)
        {
            if(++sample[s[i]-'a'] == k)
            {
                int pre = start, tail = len-i;
                while(pre < len && s[pre] != s[i])
                {
                    sample[s[pre++]-'a']--;
                }

                sample[s[i] -'a']--;
                pre++;
                int preCnt = pre-start;
                res += preCnt*tail;
                start = pre;
            }
        }

        return res;
    }
}
```
['C#']