Easy Java solution using hashmaps
\n\n# Code\njava []\nclass Solution {\n    long count = 0;\n    public long validSubstringCount(String word1, String word2) {\n        Map<Character,Integer> ma
\n\n# Code\n```java []\nclass Solution {\n    long count = 0;\n    public long validSubstringCount(String word1, String word2) {\n        Map<Character,Integer> map = new HashMap<>();\n        Map<Character,Integer> map2 = new HashMap<>();\n        for (int i = 0;i<word2.length();i++) {\n            map.put(word2.charAt(i),map.getOrDefault(word2.charAt(i),0)+1);\n        }\n        int low= 0;\n        for (int high = 0;high<word1.length();high++) {\n            map2.put(word1.charAt(high),map2.getOrDefault(word1.charAt(high),0)+1);\n            if (high-low+1 >=word2.length()) {\n                while(helper(map,map2,low,high,word1.length())){\n                    \n                    map2.put(word1.charAt(low),map2.getOrDefault(word1.charAt(low),0)-1);\n                    if (map2.containsKey(word1.charAt(low)) && map2.get(word1.charAt(low))==0) {\n                        map2.remove(word1.charAt(low));\n                    }\n                low++;\n                }\n            }\n        }\n        return count;\n    }\n\n public boolean helper (Map<Character,Integer> map,Map<Character,Integer> map2,int low,int high,int n) {\n    for (Map.Entry<Character,Integer> entry : map.entrySet()) {\n        if (!map2.containsKey(entry.getKey())) {\n            return false;\n        }\n        if (map2.get(entry.getKey()) < entry.getValue()) {\n            return false;\n        }\n    } \n    count+=(n-high);\n    return true;\n }\n}\n```
['Java']