@@ -0,0 +1,1979 @@
+//76. Minimum Window Substring%0A/**%0A * 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 empty 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 * %0A * Tags: Hash Table, Two Pointers, String%0A *%0A * Similar Problems: (H) Substring with Concatenation of All Words, (M) Minimum Size Subarray Sum, (H) Sliding Window Maximum%0A *%0A * Author: Xinyue Zhang%0A */%0A %0A public class Solution %7B%0A    public String minWindow(String s, String t) %7B%0A        if(s.isEmpty() %7C%7C t.isEmpty()) %0A            return %22%22;%0A        %0A        HashMap%3CCharacter,Integer%3E map = new HashMap%3CCharacter,Integer%3E();%0A        int count = t.length();%0A        char c;%0A        for(int i = 0; i %3C count; i++)%7B%0A            c = t.charAt(i);%0A            map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);%0A        %7D%0A        %0A        int left = 0, right = 0, len = Integer.MAX_VALUE, start = 0;%0A        while(right %3C s.length())%7B%0A            c = s.charAt(right++);%0A            if(map.containsKey(c))%7B%0A                if(map.get(c) %3E 0)%0A                    count--;%0A                map.put(c, map.get(c) - 1);%0A            %7D%0A            %0A            while(count == 0)%7B%0A                if(right - left %3C len)%7B%0A                    start = left;%0A                    len = right - left;%0A                %7D%0A                %0A                c = s.charAt(left++);%0A                if(map.containsKey(c))%7B%0A                    if(map.get(c) == 0)%0A                        count ++;%0A                    map.put(c, map.get(c) + 1);%0A                %7D%0A            %7D%0A        %7D%0A        %0A        if(len == Integer.MAX_VALUE)%0A            return %22%22;%0A        %0A        return s.substring(start, start + len);%0A    %7D%0A%7D%0A

Create 76_Minimum_Window_Substring.java