Approach similar to Aditya verma
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        int n=word1.size();\n        int m=word2.size();\n        unordered_map<char,long long>mp;\n        for(int i=0;i<m;i++){\n            mp[word2[i]]++;\n        }\n        long long count=mp.size();\n        long long i=0,j=0,ans=0;\n        while(j<n){\n            if(mp.find(word1[j])!=mp.end()){\n                mp[word1[j]]--;\n                if(mp[word1[j]]==0)\n                count--;\n            }\n            while(count==0){\n                ans+=(n-j);\n                if(mp.find(word1[i])!=mp.end()){\n                    mp[word1[i]]++;\n                    if(mp[word1[i]]>0)\n                    count++;\n                }\n                i++;\n            }\n            j++;\n        }\n        return ans;\n    }\n};\n```
['C++']