1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 08:21: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

@@ -6,7 +6,7 @@
"boundTopicId": null,
"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": null,
"translatedContent": null,
"isPaidOnly": false,