Sliding window + counting | 8 ms - beats 100.00%
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\nwher
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\nwhere `n = s.length <= 3000`\n\n# Code\n```python3 []\nclass Solution:\n    def numberOfSubstrings(self, s: str, k: int) -> int:\n        n = len(s)\n        state = Counter()\n        result = l = 0\n        for r, char in enumerate(s):\n            state[char] += 1\n            while state[char] == k:\n                result += n - r\n                state[s[l]] -= 1\n                l += 1\n        return result\n```
['Two Pointers', 'Sliding Window', 'Counting', 'Python3']