|
| 1 | +<p>Given two strings <code>s</code> and <code>t</code> of lengths <code>m</code> and <code>n</code> respectively, return <em>the <strong>minimum window</strong></em> <span data-keyword="substring-nonempty"><strong><em>substring</em></strong></span><em> of </em><code>s</code><em> such that every character in </em><code>t</code><em> (<strong>including duplicates</strong>) is included in the window</em>. If there is no such substring, return <em>the empty string </em><code>""</code>.</p> |
| 2 | + |
| 3 | +<p>The testcases will be generated such that the answer is <strong>unique</strong>.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> s = "ADOBECODEBANC", t = "ABC" |
| 10 | +<strong>Output:</strong> "BANC" |
| 11 | +<strong>Explanation:</strong> The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t. |
| 12 | +</pre> |
| 13 | + |
| 14 | +<p><strong class="example">Example 2:</strong></p> |
| 15 | + |
| 16 | +<pre> |
| 17 | +<strong>Input:</strong> s = "a", t = "a" |
| 18 | +<strong>Output:</strong> "a" |
| 19 | +<strong>Explanation:</strong> The entire string s is the minimum window. |
| 20 | +</pre> |
| 21 | + |
| 22 | +<p><strong class="example">Example 3:</strong></p> |
| 23 | + |
| 24 | +<pre> |
| 25 | +<strong>Input:</strong> s = "a", t = "aa" |
| 26 | +<strong>Output:</strong> "" |
| 27 | +<strong>Explanation:</strong> Both 'a's from t must be included in the window. |
| 28 | +Since the largest window of s only has one 'a', return empty string. |
| 29 | +</pre> |
| 30 | + |
| 31 | +<p> </p> |
| 32 | +<p><strong>Constraints:</strong></p> |
| 33 | + |
| 34 | +<ul> |
| 35 | + <li><code>m == s.length</code></li> |
| 36 | + <li><code>n == t.length</code></li> |
| 37 | + <li><code>1 <= m, n <= 10<sup>5</sup></code></li> |
| 38 | + <li><code>s</code> and <code>t</code> consist of uppercase and lowercase English letters.</li> |
| 39 | +</ul> |
| 40 | + |
| 41 | +<p> </p> |
| 42 | +<p><strong>Follow up:</strong> Could you find an algorithm that runs in <code>O(m + n)</code> time?</p> |
0 commit comments