EASY PYTHON ( explanation inside code ) same code for 3297 and 3298
\n\n# Code\npython3 []\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        n = len(word1)\n\n        dict_w2 = Counter(
\n\n# Code\n```python3 []\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        n = len(word1)\n\n        dict_w2 = Counter(word2)\n\n        match, ans, l = 0, 0, 0\n        check2, check1 = 1, 1\n\n        dict_curr = defaultdict(int)\n        for r in range(n):\n            dict_curr[word1[r]] += 1\n\n            if r >= len(word2) - 1 and ( not match ):  # check if dict_curr matches for first time with dict_w2 them make match=1\n                check1 = 1\n                for k, v in dict_w2.items():\n                    if dict_curr[k] < dict_w2[k]:\n                        check1 = 0\n                        break\n\n                match = 1 if check1 else 0\n            # after first time match of dict_curr with dict_w2 (match)\n            # check if we remove word1[l] from dict_curr it still matches with dict_w2 , if so l+=1\n            # (l) denotes right most pointer for (r) , for which dict_curr still matches with dict_w2\n\n            if match:\n                check2 = 1\n                while l < r and check2:\n                    dict_curr[word1[l]] -= 1\n                    if (word1[l] not in dict_w2) or (\n                        dict_curr[word1[l]] >= dict_w2[word1[l]]\n                    ):\n                        l += 1\n                    else:\n                        check2 = 0\n                        dict_curr[word1[l]] += 1\n\n            if match: # substring between 0 to l  (l+1 substrings)\n                ans += (l + 1)\n                \n        return ans\n\n```
['Python3']