[JavaScript] Simple Sliding Window + Hash Map Solution
Time Complexity: O(S + T) where S and T are the respective lengths of strings s and t\nSpace Complexity: O(S + T)\n\nIntuition\n\nThis is actually very similar 
Time Complexity: O(S + T) where S and T are the respective lengths of strings `s` and `t`\nSpace Complexity: O(S + T)\n\n**Intuition**\n\nThis is actually very similar to the [Permutation in String](https://leetcode.com/problems/permutation-in-string/) problem.  The difference is that we don\'t match based on string length since we aren\'t finding an exact permutation/anagram.  Instead, we want the minimal substring which means that we move our window based on finding the smallest possible solution that takes care of the counts of all the characters in `t`.  However, instead of keeping track of checking the exact count of each character each time we encounter a matching a character in `s`, we instead only need to keep track of how many unique characters there are in `t` and when a unique character goes down to 0 (or less, since having more characters than we need is okay too).  Since the length only goes down each time a character reaches exactly 0, we will never reach the count of all unique characters until every unique character has reached 0.\n\nThe key insight is that once we find the first substring that satisfies the condition, we need to start moving the left part of the window until we have the minimal substring that satisfies it since we don\'t necessarily need all the characters on the left.  In the test case provided:\n\n`s = "ADOBECODEBANC"`\n`t = "ABC"`\n\nThe minimal substring is just `BANC`, but we won\'t encounter it until we\'ve covered all of s.  At that point, we need to trim our substring from the left until we get to the minimal substring which can be accomplished with a while loop that moves the left pointer while the substring condition is true.\n\n```\n/**\n * @param {string} s\n * @param {string} t\n * @return {string}\n */\nvar minWindow = function(s, t) {\n    if (t.length > s.length) return \'\';\n    \n    const neededChars = {};\n    \n    for (let char of t) {\n        neededChars[char] = (neededChars[char] || 0) + 1;\n    }\n    \n    let left = 0;\n    let right = 0;\n    let neededLength = Object.keys(neededChars).length;\n    let substring = \'\';\n    \n    while (right < s.length) {\n        const rightChar = s[right];\n        neededChars[rightChar]--;\n        if (neededChars[rightChar] === 0) neededLength--;\n        \n        while (neededLength === 0) {\n            if (!substring || substring.length > right - left + 1) {\n                substring = s.slice(left, right + 1);\n            }\n            \n            const leftChar = s[left];\n            // If the leftChar in charMap is at exactly 0 before being \n            // incremented, we now need more leftChars so that its count\n            // in charMap goes down to exactly 0\n            if (neededChars[leftChar] === 0) {\n                neededLength++;\n            }\n            neededChars[leftChar]++;\n            left++;\n               \n        }\n        \n        right++;\n    }\n    \n    return substring;\n};\n```\n\n![image](https://assets.leetcode.com/users/images/4032e631-c774-42ff-b1ed-531364b99c7e_1658188062.4109056.png)\n
['Sliding Window', 'JavaScript']