Accepted Python solution using hashtable
class Solution:\n        # @return a string\n        def minWindow(self, S, T):\n            indices = {}\n            for char in T:\n                indices[c
    class Solution:\n        # @return a string\n        def minWindow(self, S, T):\n            indices = {}\n            for char in T:\n                indices[char] = []\n            miss = list(T)\n            start = 0\n            end = len(S)\n            for i in range(len(S)):\n                if S[i] in T:\n                    if S[i] not in miss and indices[S[i]] != []:\n                        indices[S[i]].pop(0)\n                    elif S[i] in miss:\n                        miss.remove(S[i])\n                    indices[S[i]].append(i)\n                if miss == []:\n                    maximum = max([x[-1] for x in indices.values()])\n                    minimum = min([x[0] for x in indices.values()])\n                    if maximum-minimum+1 < end-start+1:\n                        start = minimum\n                        end = maximum\n            if miss != []:\n                return ""\n            else:\n                return S[start:end+1]\n\nBasically I kept a dictionary to record the index of each character of T. Each time I found a window, (when miss == []), I checked the length of this window by subtracting the maximum index and the minimum index of the characters. If this window is the smallest one so far, I record its beginning and ending index as "start" and "end."
[]