radhe radhe || simple and easy solution || beats 100%
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        vector<int> mp2(26,0);\n        long long ans=0,n=word1.size();\n        vector<vector<int>> mp1(n,vector<int>(26,0));\n\n        mp1[0][word1[0]-\'a\']++;\n        for(auto &&val:word2)mp2[val-\'a\']++;\n        for(int i=1;i<n;i++){\n            mp1[i]=mp1[i-1];\n            mp1[i][word1[i]-\'a\']++;\n        }\n\n        for(int i=0;i<n;i++){\n            int s=i,e=n-1;\n            while(s<=e){\n                int m=s+(e-s)/2,chk=1;\n                for(int j=0;j<26;j++){\n                    int val=mp1[m][j];\n                    if(i)val-=mp1[i-1][j];\n                    if(mp2[j]>val){\n                        chk=0;\n                        break;\n                    }\n                }\n                if(chk)e=m-1;\n                else s=m+1;\n            }\n            ans+=n-s;\n        }\n\n        return ans;\n    }\n};\n```
['C++']