Accepted O(n) solution
class Solution {\n    public:\n        string minWindow(string S, string T) {\n            if (S.empty() || T.empty())\n            {\n                return ""
    class Solution {\n    public:\n        string minWindow(string S, string T) {\n            if (S.empty() || T.empty())\n            {\n                return "";\n            }\n            int count = T.size();\n            int require[128] = {0};\n            bool chSet[128] = {false};\n            for (int i = 0; i < count; ++i)\n            {\n                require[T[i]]++;\n                chSet[T[i]] = true;\n            }\n            int i = -1;\n            int j = 0;\n            int minLen = INT_MAX;\n            int minIdx = 0;\n            while (i < (int)S.size() && j < (int)S.size())\n            {\n                if (count)\n                {\n                    i++;\n                    require[S[i]]--;\n                    if (chSet[S[i]] && require[S[i]] >= 0)\n                    {\n                        count--;\n                    }\n                }\n                else\n                {\n                    if (minLen > i - j + 1)\n                    {\n                        minLen = i - j + 1;\n                        minIdx = j;\n                    }\n                    require[S[j]]++;\n                    if (chSet[S[j]] && require[S[j]] > 0)\n                    {\n                        count++;\n                    }\n                    j++;\n                }\n            }\n            if (minLen == INT_MAX)\n            {\n                return "";\n            }\n            return S.substr(minIdx, minLen);\n        }\n    };\n\nImplementation of [mike3's idea][1]\n\nrunning time : 56ms.\n\n\n  [1]: https://oj.leetcode.com/discuss/5469/is-the-length-of-t-considered-constant-or-m
[]