using map
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 []\n#define ll long long\nclass Solution {\npublic:\n    bool check(unordered_map<char, int>& mp1, unordered_map<char, int>& mp2) {\n        for (auto it : mp2) {\n            char c = it.first;\n            int n = it.second;\n            if (mp1.find(c) == mp1.end() || mp1[c] < n) return false;\n        }\n        return true;\n    }\n\n    long long validSubstringCount(string word1, string word2) {\n        unordered_map<char, int> mp2;\n        for (char c : word2) {\n            mp2[c]++;\n        }\n\n        ll ans = 0;\n        unordered_map<char, int> mp1;\n        int start = 0;\n\n        // Sliding window\n        for (int end = 0; end < word1.size(); ++end) {\n            mp1[word1[end]]++;  // Add current character to window\n\n           \n            while (end - start + 1 >= word2.size() && check(mp1, mp2)) {\n                ans += word1.size() - end;  \n                mp1[word1[start]]--;  \n                if (mp1[word1[start]] == 0) {\n                    mp1.erase(word1[start]);\n                }\n                start++;\n            }\n        }\n\n        return ans;\n    }\n};\n\n```
['C++']