🔥🔥🔥 Simple Sliding window 🔥🔥🔥
Code\npython3 []\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        dic = collections.defaultdict(int)\n        window
# Code\n```python3 []\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        dic = collections.defaultdict(int)\n        window = collections.defaultdict(int)\n        for ch in word2:\n            dic[ch] += 1\n        left = valid = count = 0\n        size = len(word1)\n        for i in range(size):\n            ch = word1[i]\n            if ch in dic:\n                window[ch] += 1\n                if window[ch] == dic[ch]:\n                    valid += 1\n            while valid == len(dic):\n                count += size - i\n                removed_ch = word1[left]\n                left += 1\n                if removed_ch in dic:\n                    if window[removed_ch] == dic[removed_ch]:\n                        valid -= 1\n                    window[removed_ch] -= 1\n        return count\n```
['Sliding Window', 'Python3']