1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/移掉 K 位数字 [remove-k-digits].html
2022-03-29 12:43:11 +08:00

37 lines
1.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个以字符串表示的非负整数 <code>num</code> 和一个整数 <code>k</code> ,移除这个数中的 <code>k</code><em> </em>位数字,使得剩下的数字最小。请你以字符串形式返回这个最小的数字。</p>
 
<p><strong>示例 1 </strong></p>
<pre>
<strong>输入:</strong>num = "1432219", k = 3
<strong>输出:</strong>"1219"
<strong>解释:</strong>移除掉三个数字 4, 3, 和 2 形成一个新的最小的数字 1219 。
</pre>
<p><strong>示例 2 </strong></p>
<pre>
<strong>输入:</strong>num = "10200", k = 1
<strong>输出:</strong>"200"
<strong>解释:</strong>移掉首位的 1 剩下的数字为 200. 注意输出不能有任何前导零。
</pre>
<p><strong>示例 3 </strong></p>
<pre>
<strong>输入:</strong>num = "10", k = 2
<strong>输出:</strong>"0"
<strong>解释:</strong>从原数字移除所有的数字,剩余为空就是 0 。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= k <= num.length <= 10<sup>5</sup></code></li>
<li><code>num</code> 仅由若干位数字0 - 9组成</li>
<li>除了 <strong>0</strong> 本身之外,<code>num</code> 不含任何前导零</li>
</ul>