c++() easy to understand solution
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 ans = 0;\n    int t[26] = {0};\n    int w[26] = {0};\n\n    for(char ch: word2) t[ch - \'a\']++;\n    int letters = 0, temp = 0;\n    for(int j = 0; j != 26; j++)\n      if(t[j]) letters++;\n\n    for(int l = 0, r = 0, k, id; r != word1.size(); r++){ \n      if(++w[id = word1[r] - \'a\'] == t[id]) temp++;\n      if(temp < letters) continue;\n\n      ans += k = word1.size() - r; \n      \n      while(true)\n        if(--w[id = word1[l] - \'a\'] < t[id]) {l++;temp--; break;}\n        else ans += k, l++;  \n    }  \n\n    return ans;    \n  }\n};\n```
['C++']