@@ -0,0 +1,1865 @@
+// Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).%0A%0A// For example,%0A// S = %22ADOBECODEBANC%22%0A// T = %22ABC%22%0A// Minimum window is %22BANC%22.%0A%0A// Note:%0A// If there is no such window in S that covers all characters in T, return the emtpy string %22%22.%0A%0A// If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S.%0A%0Apublic class Solution %7B%0A    public String minWindow(String S, String T) %7B%0A        int sLen = S.length();%0A        int tLen = T.length();%0A        if(sLen == 0 %7C%7C tLen == 0) return %22%22;%0A%0A        char%5B%5D sChars = S.toCharArray();%0A        char%5B%5D tChars = T.toCharArray();%0A%0A        HashMap%3CCharacter, Integer%3E dict = new HashMap%3CCharacter, Integer%3E();%0A        HashMap%3CCharacter, Integer%3E found = new HashMap%3CCharacter, Integer%3E();%0A%0A        for(char t : tChars)%7B%0A        %09dict.put(t, dict.containsKey(t)? dict.get(t) + 1 : 1);%0A        %09found.put(t, 0);%0A        %7D%0A%0A        int minEnd = sLen;%0A        int minStart = -1;%0A        int start = 0;%0A        int end = 0;%0A        int count = 0;%0A%0A        for(; end %3C sLen; end++)%7B%0A        %09char c = sChars%5Bend%5D;%0A        %09if(dict.containsKey(c))%7B%0A        %09%09found.put(c, found.get(c) + 1);%0A%0A        %09%09if(found.get(c) %3C= dict.get(c))%7B%0A        %09%09%09count++;%0A        %09%09%7D%0A%0A        %09%09if(count == tLen)%7B%0A        %09%09%09while(!dict.containsKey(sChars%5Bstart%5D) %7C%7C found.get(sChars%5Bstart%5D) %3E dict.get(sChars%5Bstart%5D))%7B%0A        %09%09%09%09if(dict.containsKey(sChars%5Bstart%5D))%7B%0A        %09%09%09%09%09found.put(sChars%5Bstart%5D, found.get(sChars%5Bstart%5D) - 1);%0A        %09%09%09%09%7D%0A        %09%09%09%09start++;%0A        %09%09%09%7D%0A%0A        %09%09%09if(end - start %3C minEnd - minStart)%7B%0A        %09%09%09%09minEnd = end;%0A        %09%09%09%09minStart = start;%0A        %09%09%09%7D%0A        %09%09%7D%0A        %09%7D%0A        %7D%0A%0A        return minStart == -1? %22%22 : S.substring(minStart, minEnd + 1);%0A    %7D%0A%7D

add minimum window substring solution