1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 16:31:42 +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,9 +7,9 @@
"boundTopicId": 799520,
"title": "Maximum Value after Insertion",
"titleSlug": "maximum-value-after-insertion",
"content": "<p>You are given a very large integer <code>n</code>, represented as a string, and an integer digit <code>x</code>. The digits in <code>n</code> and the digit <code>x</code> are in the <strong>inclusive</strong> range <code>[1, 9]</code>, and <code>n</code> may represent a <b>negative</b> number.</p>\n\n<p>You want to <strong>maximize </strong><code>n</code><strong>&#39;s numerical value</strong> by inserting <code>x</code> anywhere in the decimal representation of <code>n</code>. You <strong>cannot</strong> insert <code>x</code> to the left of the negative sign.</p>\n\n<ul>\n\t<li>For example, if <code>n = 73</code> and <code>x = 6</code>, it would be best to insert it between <code>7</code> and <code>3</code>, making <code>n = 763</code>.</li>\n\t<li>If <code>n = -55</code> and <code>x = 2</code>, it would be best to insert it before the first <code>5</code>, making <code>n = -255</code>.</li>\n</ul>\n\n<p>Return <em>a string representing the <strong>maximum</strong> value of </em><code>n</code><em> after the insertion</em>.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = &quot;99&quot;, x = 9\n<strong>Output:</strong> &quot;999&quot;\n<strong>Explanation:</strong> The result is the same regardless of where you insert 9.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = &quot;-13&quot;, x = 2\n<strong>Output:</strong> &quot;-123&quot;\n<strong>Explanation:</strong> You can make n one of {-213, -123, -132}, and the largest of those three is -123.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= n.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= x &lt;= 9</code></li>\n\t<li>The digits in <code>n</code> are in the range <code>[1, 9]</code>.</li>\n\t<li><code>n</code> is a valid representation of an integer.</li>\n\t<li>In the case of a negative <code>n</code>, it will begin with <code>&#39;-&#39;</code>.</li>\n</ul>\n",
"content": "<p>You are given a very large integer <code>n</code>, represented as a string, and an integer digit <code>x</code>. The digits in <code>n</code> and the digit <code>x</code> are in the <strong>inclusive</strong> range <code>[1, 9]</code>, and <code>n</code> may represent a <b>negative</b> number.</p>\n\n<p>You want to <strong>maximize </strong><code>n</code><strong>&#39;s numerical value</strong> by inserting <code>x</code> anywhere in the decimal representation of <code>n</code>. You <strong>cannot</strong> insert <code>x</code> to the left of the negative sign.</p>\n\n<ul>\n\t<li>For example, if <code>n = 73</code> and <code>x = 6</code>, it would be best to insert it between <code>7</code> and <code>3</code>, making <code>n = 763</code>.</li>\n\t<li>If <code>n = -55</code> and <code>x = 2</code>, it would be best to insert it before the first <code>5</code>, making <code>n = -255</code>.</li>\n</ul>\n\n<p>Return <em>a string representing the <strong>maximum</strong> value of </em><code>n</code><em> after the insertion</em>.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = &quot;99&quot;, x = 9\n<strong>Output:</strong> &quot;999&quot;\n<strong>Explanation:</strong> The result is the same regardless of where you insert 9.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = &quot;-13&quot;, x = 2\n<strong>Output:</strong> &quot;-123&quot;\n<strong>Explanation:</strong> You can make n one of {-213, -123, -132}, and the largest of those three is -123.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= n.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= x &lt;= 9</code></li>\n\t<li>The digits in <code>n</code> are in the range <code>[1, 9]</code>.</li>\n\t<li><code>n</code> is a valid representation of an integer.</li>\n\t<li>In the case of a negative <code>n</code>, it will begin with <code>&#39;-&#39;</code>.</li>\n</ul>\n",
"translatedTitle": "插入后的最大值",
"translatedContent": "<p>给你一个非常大的整数 <code>n</code> 和一个整数数字 <code>x</code> ,大整数 <code>n</code> 用一个字符串表示。<code>n</code> 中每一位数字和数字 <code>x</code> 都处于闭区间 <code>[1, 9]</code> 中,且 <code>n</code> 可能表示一个 <strong>负数</strong> 。</p>\n\n<p>你打算通过在 <code>n</code> 的十进制表示的任意位置插入 <code>x</code> 来 <strong>最大化</strong> <code>n</code> 的 <strong>数值</strong> 。但 <strong>不能</strong> 在负号的左边插入 <code>x</code> 。</p>\n\n<ul>\n\t<li>例如,如果 <code>n = 73</code> 且 <code>x = 6</code> ,那么最佳方案是将 <code>6</code> 插入 <code>7</code> 和 <code>3</code> 之间,使 <code>n = 763</code> 。</li>\n\t<li>如果 <code>n = -55</code> 且 <code>x = 2</code> ,那么最佳方案是将 <code>2</code> 插在第一个 <code>5</code> 之前,使 <code>n = -255</code> 。</li>\n</ul>\n\n<p>返回插入操作后,用字符串表示的 <code>n</code> 的最大值。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = \"99\", x = 9\n<strong>输出:</strong>\"999\"\n<strong>解释:</strong>不管在哪里插入 9 ,结果都是相同的。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = \"-13\", x = 2\n<strong>输出:</strong>\"-123\"\n<strong>解释:</strong>向 n 中插入 x 可以得到 -213、-123 或者 -132 ,三者中最大的是 -123 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= n.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= x <= 9</code></li>\n\t<li><code>n</code> 中每一位的数字都在闭区间 <code>[1, 9]</code> 中。</li>\n\t<li><code>n</code> 代表一个有效的整数。</li>\n\t<li>当 <code>n</code> 表示负数时,将会以字符 <code>'-'</code> 开始。</li>\n</ul>\n",
"translatedContent": "<p>给你一个非常大的整数 <code>n</code> 和一个整数数字 <code>x</code> ,大整数 <code>n</code> 用一个字符串表示。<code>n</code> 中每一位数字和数字 <code>x</code> 都处于闭区间 <code>[1, 9]</code> 中,且 <code>n</code> 可能表示一个 <strong>负数</strong> 。</p>\n\n<p>你打算通过在 <code>n</code> 的十进制表示的任意位置插入 <code>x</code> 来 <strong>最大化</strong> <code>n</code> 的 <strong>数值</strong> 。但 <strong>不能</strong> 在负号的左边插入 <code>x</code> 。</p>\n\n<ul>\n\t<li>例如,如果 <code>n = 73</code> 且 <code>x = 6</code> ,那么最佳方案是将 <code>6</code> 插入 <code>7</code> 和 <code>3</code> 之间,使 <code>n = 763</code> 。</li>\n\t<li>如果 <code>n = -55</code> 且 <code>x = 2</code> ,那么最佳方案是将 <code>2</code> 插在第一个 <code>5</code> 之前,使 <code>n = -255</code> 。</li>\n</ul>\n\n<p>返回插入操作后,用字符串表示的 <code>n</code> 的最大值。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = \"99\", x = 9\n<strong>输出:</strong>\"999\"\n<strong>解释:</strong>不管在哪里插入 9 ,结果都是相同的。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = \"-13\", x = 2\n<strong>输出:</strong>\"-123\"\n<strong>解释:</strong>向 n 中插入 x 可以得到 -213、-123 或者 -132 ,三者中最大的是 -123 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= n.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= x <= 9</code></li>\n\t<li><code>n</code> 中每一位的数字都在闭区间 <code>[1, 9]</code> 中。</li>\n\t<li><code>n</code> 代表一个有效的整数。</li>\n\t<li>当 <code>n</code> 表示负数时,将会以字符 <code>'-'</code> 开始。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 25,