C++ solution Sliding Window
\n// Please, upvote if you like it. Thanks :-)\nlong long validSubstringCount(string word1, string word2) {\n\tlong long res = 0, cnt = 0;\n\tunordered_map<char
```\n// Please, upvote if you like it. Thanks :-)\nlong long validSubstringCount(string word1, string word2) {\n\tlong long res = 0, cnt = 0;\n\tunordered_map<char, int> mp;\n\tfor (const char& c : word2) {\n\t\tif (mp[c] == 0)\n\t\t\tcnt++;\n\t\tmp[c]++;\n\t}\n\tint sz1 = word1.size(), i = 0, j = 0;\n\twhile (i < sz1) {\n\t\tif (--mp[word1[i]] == 0)\n\t\t\tcnt--;\n\t\twhile (cnt == 0) {\n\t\t\tres += (sz1 - i);\n\t\t\tcnt += (mp[word1[j]] == 0);\n\t\t\tmp[word1[j]]++;\n\t\t\tj++;\n\t\t}\n\t\ti++;\n\t}\n\treturn res;\n}\n```
['Hash Table', 'Two Pointers', 'String', 'C', 'Sliding Window', 'C++']