Sliding window | c++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long validSubstringCount(string word1, string word2) {\n        long long counter=word2.size();\n        unordered_map<char, int>mp;\n        int n = word1.size(), m=word2.size();\n        long long ans = 0, l=0, r=0;\n\n        for(auto x:word2) mp[x]++;\n\n        while(r<n) {\n            if(mp[word1[r]]>0){\n                counter--;\n            }\n\n            mp[word1[r]]--;\n\n            while(counter==0) {\n                ans+=(n-r); // add all after words\n                mp[word1[l]]++;\n                if(mp[word1[l]]>0){\n                    counter++;\n                }\n                l++;\n            }\n            r++;\n        }\n        return ans;\n    }\n};\n```
['C++']