Golang Sliding Window with Key observation
Intuition\n Describe your first thoughts on how to solve this problem. \nVery similar to Min substring. \nWe will solve using using sliding window. \n\nThe key 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nVery similar to Min substring. \nWe will solve using using sliding window. \n\nThe key observation that I always used to mess up was, if a substring i to j in word1 is valid, how many substrings will that add to my result. \n\nThe answer there is, if substring i to j is valid, it will add len(word1) - j substrings to my result.\n\nWhy? \n\nabcabc\nif abc is valid, abca, abcab and abcabc is also valid, since all of these can be rearragened to have abc as its prefix.\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```golang []\nfunc validSubstringCount(word1 string, word2 string) int64 {\n    n := len(word1)\n\n\n    w1Map := map[byte] int{} \n    w2Map := map[byte] int{} \n\n    for _, c := range word2 {\n        w2Map[byte(c)]++\n    }\n\n    left, right := 0, 0 \n    count := len(word2)\n\n    var sCount int64 = 0\n    for right < n {\n        c := word1[right]\n        w1Map[c]++\n        if w1Map[c] <= w2Map[c] {\n            count--\n        }\n\n        for count == 0 {\n            sCount += int64(len(word1) - right)\n            sChar := word1[left]\n            w1Map[sChar]--\n            left++ \n            if w1Map[sChar] < w2Map[sChar] {\n                count++\n            }\n        }\n\n        right++\n    }\n\n    return sCount\n}\n```
['Go']