1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-25 17:50:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最小覆盖子串 [minimum-window-substring].html
2022-03-29 12:43:11 +08:00

46 lines
1.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串 <code>s</code> 、一个字符串 <code>t</code> 。返回 <code>s</code> 中涵盖 <code>t</code> 所有字符的最小子串。如果 <code>s</code> 中不存在涵盖 <code>t</code> 所有字符的子串,则返回空字符串 <code>""</code></p>
<p> </p>
<p><strong>注意:</strong></p>
<ul>
<li>对于 <code>t</code> 中重复字符,我们寻找的子字符串中该字符数量必须不少于 <code>t</code> 中该字符数量。</li>
<li>如果 <code>s</code> 中存在这样的子串,我们保证它是唯一的答案。</li>
</ul>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "ADOBECODEBANC", t = "ABC"
<strong>输出:</strong>"BANC"
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "a", t = "a"
<strong>输出:</strong>"a"
</pre>
<p><strong>示例 3:</strong></p>
<pre>
<strong>输入:</strong> s = "a", t = "aa"
<strong>输出:</strong> ""
<strong>解释:</strong> t 中两个字符 'a' 均应包含在 s 的子串中,
因此没有符合条件的子字符串,返回空字符串。</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= s.length, t.length <= 10<sup>5</sup></code></li>
<li><code>s</code><code>t</code> 由英文字母组成</li>
</ul>
<p> </p>
<strong>进阶:</strong>你能设计一个在 <code>o(n)</code> 时间内解决此问题的算法吗?