java.lang.Object
g0001_0100.s0076_minimum_window_substring.Solution

public class Solution extends Object
76 - Minimum Window Substring.<p>Hard</p> <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 substring</strong> 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. If there is no such substring</em>_, return the empty string_ <code>&quot;&quot;</code><em>.</em></p> <p>The testcases will be generated such that the answer is <strong>unique</strong>.</p> <p>A <strong>substring</strong> is a contiguous sequence of characters within the string.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;ADOBECODEBANC&rdquo;, t = &ldquo;ABC&rdquo;</p> <p><strong>Output:</strong> &ldquo;BANC&rdquo;</p> <p><strong>Explanation:</strong> The minimum window substring &ldquo;BANC&rdquo; includes &lsquo;A&rsquo;, &lsquo;B&rsquo;, and &lsquo;C&rsquo; from string t.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;a&rdquo;, t = &ldquo;a&rdquo;</p> <p><strong>Output:</strong> &ldquo;a&rdquo;</p> <p><strong>Explanation:</strong> The entire string s is the minimum window.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;a&rdquo;, t = &ldquo;aa&rdquo;</p> <p><strong>Output:</strong> &quot;&quot;</p> <p><strong>Explanation:</strong> Both &rsquo;a&rsquo;s from t must be included in the window. Since the largest window of s only has one &lsquo;a&rsquo;, return empty string.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>m == s.length</code></li> <li><code>n == t.length</code></li> <li><code>1 <= m, n <= 10<sup>5</sup></code></li> <li><code>s</code> and <code>t</code> consist of uppercase and lowercase English letters.</li> </ul> <p><strong>Follow up:</strong> Could you find an algorithm that runs in <code>O(m + n)</code> time?</p>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details