1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-21 13:06:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个字符串 <code>s</code> 、一个字符串 <code>t</code> 。返回 <code>s</code> 中涵盖 <code>t</code> 所有字符的最小子串。如果 <code>s</code> 中不存在涵盖 <code>t</code> 所有字符的子串,则返回空字符串 <code>\"\"</code> 。</p>\n\n<p> </p>\n\n<p><strong>注意:</strong></p>\n\n<ul>\n\t<li>对于 <code>t</code> 中重复字符,我们寻找的子字符串中该字符数量必须不少于 <code>t</code> 中该字符数量。</li>\n\t<li>如果 <code>s</code> 中存在这样的子串,我们保证它是唯一的答案。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"ADOBECODEBANC\", t = \"ABC\"\n<strong>输出:</strong>\"BANC\"\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"a\", t = \"a\"\n<strong>输出:</strong>\"a\"\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong> s = \"a\", t = \"aa\"\n<strong>输出:</strong> \"\"\n<strong>解释:</strong> t 中两个字符 'a' 均应包含在 s 的子串中,\n因此没有符合条件的子字符串返回空字符串。</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length, t.length <= 10<sup>5</sup></code></li>\n\t<li><code>s</code> 和 <code>t</code> 由英文字母组成</li>\n</ul>\n\n<p> </p>\n<strong>进阶:</strong>你能设计一个在 <code>o(n)</code> 时间内解决此问题的算法吗?",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 1752,
"likes": 1824,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Substring with Concatenation of All Words\", \"titleSlug\": \"substring-with-concatenation-of-all-words\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u4e32\\u8054\\u6240\\u6709\\u5355\\u8bcd\\u7684\\u5b50\\u4e32\"}, {\"title\": \"Minimum Size Subarray Sum\", \"titleSlug\": \"minimum-size-subarray-sum\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u957f\\u5ea6\\u6700\\u5c0f\\u7684\\u5b50\\u6570\\u7ec4\"}, {\"title\": \"Sliding Window Maximum\", \"titleSlug\": \"sliding-window-maximum\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u6ed1\\u52a8\\u7a97\\u53e3\\u6700\\u5927\\u503c\"}, {\"title\": \"Permutation in String\", \"titleSlug\": \"permutation-in-string\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u5b57\\u7b26\\u4e32\\u7684\\u6392\\u5217\"}, {\"title\": \"Minimum Window Subsequence\", \"titleSlug\": \"minimum-window-subsequence\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u6700\\u5c0f\\u7a97\\u53e3\\u5b50\\u5e8f\\u5217\"}]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"257.2K\", \"totalSubmission\": \"587.5K\", \"totalAcceptedRaw\": 257186, \"totalSubmissionRaw\": 587463, \"acRate\": \"43.8%\"}",
"stats": "{\"totalAccepted\": \"272.9K\", \"totalSubmission\": \"620.7K\", \"totalAcceptedRaw\": 272910, \"totalSubmissionRaw\": 620708, \"acRate\": \"44.0%\"}",
"hints": [
"Use two pointers to create a window of letters in <b>S</b>, which would have all the characters from <b>T</b>.",
"Since you have to find the minimum window in <b>S</b> which has all the characters from <b>T</b>, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is also called Sliding Window Approach.\r\n\r\n<br><br>\r\n<pre>\r\nL ------------------------ R , Suppose this is the window that contains all characters of <b>T</b> \r\n \r\n&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp L----------------- R , this is the contracted window. We found a smaller window that still contains all the characters in <b>T</b>\r\n\r\nWhen the window is no longer valid, start expanding again using the right pointer. </pre>"