代码拉取完成,页面将自动刷新
同步操作将从 小墨/力扣题库(完整版) 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<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>
<p>You want to <strong>maximize </strong><code>n</code><strong>'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>
<ul>
<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>
<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>
</ul>
<p>Return <em>a string representing the <strong>maximum</strong> value of </em><code>n</code><em> after the insertion</em>.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> n = "99", x = 9
<strong>Output:</strong> "999"
<strong>Explanation:</strong> The result is the same regardless of where you insert 9.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> n = "-13", x = 2
<strong>Output:</strong> "-123"
<strong>Explanation:</strong> You can make n one of {-213, -123, -132}, and the largest of those three is -123.
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n.length <= 10<sup>5</sup></code></li>
<li><code>1 <= x <= 9</code></li>
<li>The digits in <code>n</code> are in the range <code>[1, 9]</code>.</li>
<li><code>n</code> is a valid representation of an integer.</li>
<li>In the case of a negative <code>n</code>, it will begin with <code>'-'</code>.</li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。