Basic sliding window easy
Code\npython3 []\nfrom collections import defaultdict\n\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        word2_dict 
# Code\n```python3 []\nfrom collections import defaultdict\n\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        word2_dict = defaultdict(int)\n        for c in word2:\n            word2_dict[c] += 1\n        l = 0\n        res = 0\n        n = len(word1)\n        required_matches = len(word2)\n        match_count = 0  # Track how many matches we have\n\n        for r in range(n):\n            if word1[r] in word2_dict:\n                if word2_dict[word1[r]] > 0:\n                    match_count += 1\n                word2_dict[word1[r]] -= 1\n\n            while match_count == required_matches:\n                res += (n - r)\n                if word1[l] in word2_dict:\n                    word2_dict[word1[l]] += 1\n                    if word2_dict[word1[l]] > 0:\n                        match_count -= 1\n                l += 1\n\n        return res\n```
['Hash Table', 'Sliding Window', 'Python3']