Simple Solution || Sliding Window || Time: O(n) and Space: O(1)
Approach\n Describe your approach to solving the problem. \n- Assume all are valid senarios and compute the total number of cases which is n(n + 1) / 2.\n- Now 
# Approach\n<!-- Describe your approach to solving the problem. -->\n- Assume all are valid senarios and compute the total number of cases which is **n(n + 1) / 2**.\n- Now remove the substrings which are invalid.\n\n# Complexity\n- Time complexity: **O(n)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: **O(1)** since only for fixed size of O(26)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def numberOfSubstrings(self, s: str, k: int) -> int:\n        \n        n = len(s)\n        i = j = 0\n        hashMap = defaultdict(int)\n        count = int((n * (n + 1)) / 2)\n\n        while j < n:\n            # Count frequency of the alphabet\n            hashMap[s[j]] += 1\n            # Move i till the subtring is invalid\n            while i <= j and hashMap[s[j]] == k:\n                hashMap[s[i]] -= 1\n                i += 1\n            # Remove the invalid cases from computed result\n            count -= (j - i + 1)\n            j += 1\n\n        return count\n```
['Array', 'Hash Table', 'Math', 'Sliding Window', 'Python3']