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": 752468,
"title": "Splitting a String Into Descending Consecutive Values",
"titleSlug": "splitting-a-string-into-descending-consecutive-values",
"content": "<p>You are given a string <code>s</code> that consists of only digits.</p>\n\n<p>Check if we can split <code>s</code> into <strong>two or more non-empty substrings</strong> such that the <strong>numerical values</strong> of the substrings are in <strong>descending order</strong> and the <strong>difference</strong> between numerical values of every two <strong>adjacent</strong> <strong>substrings</strong> is equal to <code>1</code>.</p>\n\n<ul>\n\t<li>For example, the string <code>s = &quot;0090089&quot;</code> can be split into <code>[&quot;0090&quot;, &quot;089&quot;]</code> with numerical values <code>[90,89]</code>. The values are in descending order and adjacent values differ by <code>1</code>, so this way is valid.</li>\n\t<li>Another example, the string <code>s = &quot;001&quot;</code> can be split into <code>[&quot;0&quot;, &quot;01&quot;]</code>, <code>[&quot;00&quot;, &quot;1&quot;]</code>, or <code>[&quot;0&quot;, &quot;0&quot;, &quot;1&quot;]</code>. However all the ways are invalid because they have numerical values <code>[0,1]</code>, <code>[0,1]</code>, and <code>[0,0,1]</code> respectively, all of which are not in descending order.</li>\n</ul>\n\n<p>Return <code>true</code> <em>if it is possible to split</em> <code>s</code> <em>as described above</em><em>, or </em><code>false</code><em> otherwise.</em></p>\n\n<p>A <strong>substring</strong> is a contiguous sequence of characters in 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;1234&quot;\n<strong>Output:</strong> false\n<strong>Explanation:</strong> There is no valid way to split s.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = &quot;050043&quot;\n<strong>Output:</strong> true\n<strong>Explanation:</strong> s can be split into [&quot;05&quot;, &quot;004&quot;, &quot;3&quot;] with numerical values [5,4,3].\nThe values are in descending order with adjacent values differing by 1.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = &quot;9080701&quot;\n<strong>Output:</strong> false\n<strong>Explanation:</strong> There is no valid way to split s.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length &lt;= 20</code></li>\n\t<li><code>s</code> only consists of digits.</li>\n</ul>\n",
"content": "<p>You are given a string <code>s</code> that consists of only digits.</p>\n\n<p>Check if we can split <code>s</code> into <strong>two or more non-empty substrings</strong> such that the <strong>numerical values</strong> of the substrings are in <strong>descending order</strong> and the <strong>difference</strong> between numerical values of every two <strong>adjacent</strong> <strong>substrings</strong> is equal to <code>1</code>.</p>\n\n<ul>\n\t<li>For example, the string <code>s = &quot;0090089&quot;</code> can be split into <code>[&quot;0090&quot;, &quot;089&quot;]</code> with numerical values <code>[90,89]</code>. The values are in descending order and adjacent values differ by <code>1</code>, so this way is valid.</li>\n\t<li>Another example, the string <code>s = &quot;001&quot;</code> can be split into <code>[&quot;0&quot;, &quot;01&quot;]</code>, <code>[&quot;00&quot;, &quot;1&quot;]</code>, or <code>[&quot;0&quot;, &quot;0&quot;, &quot;1&quot;]</code>. However all the ways are invalid because they have numerical values <code>[0,1]</code>, <code>[0,1]</code>, and <code>[0,0,1]</code> respectively, all of which are not in descending order.</li>\n</ul>\n\n<p>Return <code>true</code> <em>if it is possible to split</em> <code>s</code> <em>as described above</em><em>, or </em><code>false</code><em> otherwise.</em></p>\n\n<p>A <strong>substring</strong> is a contiguous sequence of characters in 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;1234&quot;\n<strong>Output:</strong> false\n<strong>Explanation:</strong> There is no valid way to split s.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = &quot;050043&quot;\n<strong>Output:</strong> true\n<strong>Explanation:</strong> s can be split into [&quot;05&quot;, &quot;004&quot;, &quot;3&quot;] with numerical values [5,4,3].\nThe values are in descending order with adjacent values differing by 1.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> s = &quot;9080701&quot;\n<strong>Output:</strong> false\n<strong>Explanation:</strong> There is no valid way to split s.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= s.length &lt;= 20</code></li>\n\t<li><code>s</code> only consists of digits.</li>\n</ul>\n",
"translatedTitle": "将字符串拆分为递减的连续值",
"translatedContent": "<p>给你一个仅由数字组成的字符串 <code>s</code> 。</p>\n\n<p>请你判断能否将 <code>s</code> 拆分成两个或者多个 <strong>非空子字符串</strong> ,使子字符串的 <strong>数值</strong> 按 <strong>降序</strong> 排列,且每两个 <strong>相邻子字符串</strong> 的数值之 <strong>差 </strong>等于 <code>1</code> 。</p>\n\n<ul>\n\t<li>例如,字符串 <code>s = \"0090089\"</code> 可以拆分成 <code>[\"0090\", \"089\"]</code> ,数值为 <code>[90,89]</code> 。这些数值满足按降序排列,且相邻值相差 <code>1</code> ,这种拆分方法可行。</li>\n\t<li>另一个例子中,字符串 <code>s = \"001\"</code> 可以拆分成 <code>[\"0\", \"01\"]</code>、<code>[\"00\", \"1\"]</code> 或 <code>[\"0\", \"0\", \"1\"]</code> 。然而,所有这些拆分方法都不可行,因为对应数值分别是 <code>[0,1]</code>、<code>[0,1]</code> 和 <code>[0,0,1]</code> ,都不满足按降序排列的要求。</li>\n</ul>\n\n<p>如果可以按要求拆分 <code>s</code> ,返回 <code>true</code> ;否则,返回 <code>false</code><em> </em>。</p>\n\n<p><strong>子字符串</strong> 是字符串中的一个连续字符序列。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"1234\"\n<strong>输出:</strong>false\n<strong>解释:</strong>不存在拆分 s 的可行方法。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"050043\"\n<strong>输出:</strong>true\n<strong>解释:</strong>s 可以拆分为 [\"05\", \"004\", \"3\"] ,对应数值为 [5,4,3] 。\n满足按降序排列且相邻值相差 <code>1</code> 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"9080701\"\n<strong>输出:</strong>false\n<strong>解释:</strong>不存在拆分 s 的可行方法。\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"10009998\"\n<strong>输出:</strong>true\n<strong>解释:</strong>s 可以拆分为 [\"100\", \"099\", \"98\"] ,对应数值为 [100,99,98] 。\n满足按降序排列且相邻值相差 <code>1</code> 。</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length <= 20</code></li>\n\t<li><code>s</code> 仅由数字组成</li>\n</ul>\n",
"isPaidOnly": false,