Java Easy 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```java []\nclass Solution {\n    public long validSubstringCount(String word1, String word2) {\n\n        int t[] = new int[26];\n\n        for(int i=0;i<word2.length();i++){\n            t[word2.charAt(i)-\'a\']++;\n        }\n\n        int dp[] = new int[26];\n\n        int j=0;\n        long ans = 0l;\n        for(int i=0;i<word1.length();i++){\n           dp[word1.charAt(i)-\'a\']++;\n           if(i-j+1 >= word2.length() && isvalid(dp, t)){\n            ans += word1.length()-i;\n            while(j<i && t[word1.charAt(j)-\'a\']<dp[word1.charAt(j)-\'a\']){\n              dp[word1.charAt(j)-\'a\']--;\n              ans+=word1.length()-i;\n              j++;\n            }\n            dp[word1.charAt(j)-\'a\']--;\n            j++;\n           }\n        }\n\n        return ans;\n        \n    }\n\n    private boolean isvalid(int dp[], int t[]){\n\n\n        for(int i=0;i<26;i++){\n            if(dp[i]<t[i])\n            return false;\n        }\n        return true;\n    }\n}\n```
['Java']