C++ | Easy | Sliding Window Implementation
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    bool isValidPrefix(vector<int> &freq1, vector<int> &freq2){\n        for(int i=0; i<26; i++){\n            if(freq1[i] < freq2[i]){\n                return false;\n            }\n        }\n        return true;\n    }\n    long long validSubstringCount(string word1, string word2) {\n        vector<int> freq1(26, 0);\n        vector<int> freq2(26, 0);\n        for(int i=0; i<word2.size(); i++){\n            freq2[word2[i]-\'a\']++;\n        }\n        int w1Size = word1.size();\n        long long int count = 0;\n        int start = 0;\n        for(int end=0; end< w1Size; end++){\n            freq1[word1[end]-\'a\']++;\n            while(start <= end and isValidPrefix(freq1, freq2)){\n                count+=(w1Size - end);\n                freq1[word1[start]-\'a\']--;\n                start++;\n            }\n        }\n        return count;\n\n    }\n};\n```
['C++']