1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-06 07:51:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

移除零宽空格

This commit is contained in:
2025-05-25 15:06:02 +08:00
parent 59597532bc
commit 3070bed723
272 changed files with 1031 additions and 749 deletions

View File

@@ -7,7 +7,7 @@
"boundTopicId": 466348,
"title": "Count Substrings That Differ by One Character",
"titleSlug": "count-substrings-that-differ-by-one-character",
"content": "<p>Given two strings <code>s</code> and <code>t</code>, find the number of ways you can choose a non-empty substring of <code>s</code> and replace a <strong>single character</strong> by a different character such that the resulting substring is a substring of <code>t</code>. In other words, find the number of substrings in <code>s</code> that differ from some substring in <code>t</code> by <strong>exactly</strong> one character.</p>\n\n<p>For example, the underlined substrings in <code>&quot;<u>compute</u>r&quot;</code> and <code>&quot;<u>computa</u>tion&quot;</code> only differ by the <code>&#39;e&#39;</code>/<code>&#39;a&#39;</code>, so this is a valid way.</p>\n\n<p>Return <em>the number of substrings that satisfy the condition above.</em></p>\n\n<p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = &quot;aba&quot;, t = &quot;baba&quot;\n<strong>Output:</strong> 6\n<strong>Explanation:</strong> The following are the pairs of substrings from s and t that differ by exactly 1 character:\n(&quot;<u>a</u>ba&quot;, &quot;<u>b</u>aba&quot;)\n(&quot;<u>a</u>ba&quot;, &quot;ba<u>b</u>a&quot;)\n(&quot;ab<u>a</u>&quot;, &quot;<u>b</u>aba&quot;)\n(&quot;ab<u>a</u>&quot;, &quot;ba<u>b</u>a&quot;)\n(&quot;a<u>b</u>a&quot;, &quot;b<u>a</u>ba&quot;)\n(&quot;a<u>b</u>a&quot;, &quot;bab<u>a</u>&quot;)\nThe underlined portions are the substrings that are chosen from s and t.\n</pre>\n<strong class=\"example\">Example 2:</strong>\n\n<pre>\n<strong>Input:</strong> s = &quot;ab&quot;, t = &quot;bb&quot;\n<strong>Output:</strong> 3\n<strong>Explanation:</strong> The following are the pairs of substrings from s and t that differ by 1 character:\n(&quot;<u>a</u>b&quot;, &quot;<u>b</u>b&quot;)\n(&quot;<u>a</u>b&quot;, &quot;b<u>b</u>&quot;)\n(&quot;<u>ab</u>&quot;, &quot;<u>bb</u>&quot;)\nThe underlined portions are the substrings that are chosen from s and t.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length, t.length &lt;= 100</code></li>\n\t<li><code>s</code> and <code>t</code> consist of lowercase English letters only.</li>\n</ul>\n",
"content": "<p>Given two strings <code>s</code> and <code>t</code>, find the number of ways you can choose a non-empty substring of <code>s</code> and replace a <strong>single character</strong> by a different character such that the resulting substring is a substring of <code>t</code>. In other words, find the number of substrings in <code>s</code> that differ from some substring in <code>t</code> by <strong>exactly</strong> one character.</p>\n\n<p>For example, the underlined substrings in <code>&quot;<u>compute</u>r&quot;</code> and <code>&quot;<u>computa</u>tion&quot;</code> only differ by the <code>&#39;e&#39;</code>/<code>&#39;a&#39;</code>, so this is a valid way.</p>\n\n<p>Return <em>the number of substrings that satisfy the condition above.</em></p>\n\n<p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = &quot;aba&quot;, t = &quot;baba&quot;\n<strong>Output:</strong> 6\n<strong>Explanation:</strong> The following are the pairs of substrings from s and t that differ by exactly 1 character:\n(&quot;<u>a</u>ba&quot;, &quot;<u>b</u>aba&quot;)\n(&quot;<u>a</u>ba&quot;, &quot;ba<u>b</u>a&quot;)\n(&quot;ab<u>a</u>&quot;, &quot;<u>b</u>aba&quot;)\n(&quot;ab<u>a</u>&quot;, &quot;ba<u>b</u>a&quot;)\n(&quot;a<u>b</u>a&quot;, &quot;b<u>a</u>ba&quot;)\n(&quot;a<u>b</u>a&quot;, &quot;bab<u>a</u>&quot;)\nThe underlined portions are the substrings that are chosen from s and t.\n</pre>\n<strong class=\"example\">Example 2:</strong>\n\n<pre>\n<strong>Input:</strong> s = &quot;ab&quot;, t = &quot;bb&quot;\n<strong>Output:</strong> 3\n<strong>Explanation:</strong> The following are the pairs of substrings from s and t that differ by 1 character:\n(&quot;<u>a</u>b&quot;, &quot;<u>b</u>b&quot;)\n(&quot;<u>a</u>b&quot;, &quot;b<u>b</u>&quot;)\n(&quot;<u>ab</u>&quot;, &quot;<u>bb</u>&quot;)\nThe underlined portions are the substrings that are chosen from s and t.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length, t.length &lt;= 100</code></li>\n\t<li><code>s</code> and <code>t</code> consist of lowercase English letters only.</li>\n</ul>\n",
"translatedTitle": "统计只差一个字符的子串数目",
"translatedContent": "<p>给你两个字符串&nbsp;<code>s</code> 和&nbsp;<code>t</code>&nbsp;,请你找出 <code>s</code>&nbsp;中的非空子串的数目,这些子串满足替换 <strong>一个不同字符</strong>&nbsp;以后,是 <code>t</code>&nbsp;串的子串。换言之,请你找到 <code>s</code>&nbsp;和 <code>t</code>&nbsp;串中 <strong>恰好</strong>&nbsp;只有一个字符不同的子字符串对的数目。</p>\n\n<p>比方说,&nbsp;<code>\"<u>compute</u>r\"</code>&nbsp;and&nbsp;<code>\"<u>computa</u>tion\"&nbsp;</code>只有一个字符不同:&nbsp;<code>'e'</code>/<code>'a'</code>&nbsp;,所以这一对子字符串会给答案加 1 。</p>\n\n<p>请你返回满足上述条件的不同子字符串对数目。</p>\n\n<p>一个 <strong>子字符串</strong>&nbsp;是一个字符串中连续的字符。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>s = \"aba\", t = \"baba\"\n<b>输出:</b>6\n<strong>解释:</strong>以下为只相差 1 个字符的 s 和 t 串的子字符串对:\n(\"<strong>a</strong>ba\", \"<strong>b</strong>aba\")\n(\"<strong>a</strong>ba\", \"ba<strong>b</strong>a\")\n(\"ab<strong>a</strong>\", \"<strong>b</strong>aba\")\n(\"ab<strong>a</strong>\", \"ba<strong>b</strong>a\")\n(\"a<strong>b</strong>a\", \"b<strong>a</strong>ba\")\n(\"a<strong>b</strong>a\", \"bab<strong>a</strong>\")\n加粗部分分别表示 s 和 t 串选出来的子字符串。\n</pre>\n<strong>示例 2</strong>\n\n<pre>\n<b>输入:</b>s = \"ab\", t = \"bb\"\n<b>输出:</b>3\n<strong>解释:</strong>以下为只相差 1 个字符的 s 和 t 串的子字符串对:\n(\"<strong>a</strong>b\", \"<strong>b</strong>b\")\n(\"<strong>a</strong>b\", \"b<strong>b</strong>\")\n(\"<strong>ab</strong>\", \"<strong>bb</strong>\")\n加粗部分分别表示 s 和 t 串选出来的子字符串。\n</pre>\n<strong>示例 3</strong>\n\n<pre>\n<b>输入:</b>s = \"a\", t = \"a\"\n<b>输出:</b>0\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre>\n<b>输入:</b>s = \"abe\", t = \"bbc\"\n<b>输出:</b>10\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length, t.length &lt;= 100</code></li>\n\t<li><code>s</code> 和&nbsp;<code>t</code>&nbsp;都只包含小写英文字母。</li>\n</ul>\n",
"isPaidOnly": false,