diff --git a/cpp program for minimum window substring b/cpp program for minimum window substring new file mode 100644 index 00000000..bc04d403 --- /dev/null +++ b/cpp program for minimum window substring @@ -0,0 +1,27 @@ +string minWindow(string s, string t) { + if(s.size() < t.size()){ + return ""; + } + unordered_map map; + for(int i=0;i0){ + count++; + } + map[s[end]]--; + if(count == t.length()) { + while(start < end && map[s[start]] < 0){ + map[s[start]]++, start++; + } + if(min_length > end-start){ + min_length = end-(min_start=start)+1; + } + map[s[start++]]++; + count--; + } + } + return min_length == INT_MAX ? "" : s.substr(min_start, min_length); + }