67. Minimum Window Substring

Given two strings s and t. Find the smallest window substring of s that includes all characters in t (including duplicates) , in the window. Return the empty string "" if no such substring exists.

Example 1:

Input : s = "ADOBECODEBANC" , t = "ABC"

Output : "BANC"

Explanation : The minimum window substring of string s that contains the string t is "BANC".

Example 2:

Input : s = "a" , t = "a"

Output : "a"

Explanation : The complete string is the minimum window

Now Your Turn!

Pick the correct output for the given input

Input : s = "aAbBDdcC" , t = "Bc"

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n , m <= 105
  • n = s.length
  • m = t.length
  • string s and t consist of uppercase and lowercase letters.

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
string minWindow(string s, string t) {
//your code goes here
}
};
Test Case

Input:

S
T