Sliding Window
Nothing new here, similar to 76. Minimum Window Substring. \n\nWe track if a string [j, i] contains all characters in w2.\n\n> For that, we decrement match when
Nothing new here, similar to [76. Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring). \n\nWe track if a string `[j, i]` contains all characters in `w2`.\n\n> For that, we decrement `match` when the remaining character count reaches zero.\n\nIf it does, we add `len(w2) - i` to the result, and increment `j`.\n\n**C++**\n```cpp\nlong long validSubstringCount(string w1, string w2) {\n    long long cnt[26] = {}, j = 0, match = 0, res = 0;\n    for (char ch : w2)\n        match += cnt[ch - \'a\']++ == 0;\n    for (int i = 0; i < w1.size(); ++i) {\n        --cnt[w1[i] - \'a\'];\n        match -= cnt[w1[i] - \'a\'] == 0; \n        while (match == 0) {\n            res += w1.size() - i;\n            match += cnt[w1[j] - \'a\'] == 0;\n            ++cnt[w1[j++] - \'a\'];\n        }\n    }\n    return res;\n}\n```
['C']