Python 20 lines AC O(n) solution
Idea is pretty simple, keep two pointers left and right.\n\n If s[left:right] has all chars in T, calculate distance and keep answer, then move left pointer.\n\
Idea is pretty simple, keep two pointers left and right.\n\n If s[left:right] has all chars in T, calculate distance and keep answer, then move left pointer.\n\n If s[left:right] doesn't have all chars in T, move right pointer.\n\n\n    class Solution:\n    # @param {string} s\n    # @param {string} t\n    # @return {string}\n    # sliding window problem\n    # count all chars in string T\n    # left pointer point to string which has been processed\n    # right pointer point to string, which has not been processed\n    # 1.if all window from left to right contains all string T(counter values all less then or equal to 0)\n    #   calculate min window length, and keep answer\n    #   then move left pointer\n    # 2.else there are missing string in current answer\n    #   move right pointer\n    #   update counter\n    # repeat 1, 2 steps until right is equal to len(s), then break it\n    def minWindow(self, s, t):\n        left, right = 0, 0\n        # count T chars\n        counter = collections.defaultdict(int)\n        for a in t:\n            counter[a] += 1\n        \n        minwindow = len(s) + 1\n        answer = None\n        \n        while right <= len(s):\n            # check all chars in T are in the current answer\n            if all(map(lambda x: True if x<=0 else False, counter.values())):\n                if minwindow > right-left:\n                    minwindow = right-left\n                    answer = s[left:right]\n                char = s[left]\n                if char in counter:\n                    counter[char] += 1\n                left += 1\n            else:\n                if right == len(s):\n                    break\n                char = s[right]\n                if char in counter:\n                    counter[char] -= 1\n                right += 1\n                \n        return answer if answer else ''
['Python']